Created
August 18, 2016 10:54
-
-
Save Jezza/8d7171afe237304d35aaf3175349d340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implicit declarations | |
ALPHA_LOWER := [a-z] | |
ALPHA_UPPER := [A-Z] | |
ALPHA := [{ALPHA_LOWER}|{ALPHA_UPPER}] | |
NUM := [0-9] | |
HEX := [{NUM}|a|b|c|d|e|f|A|B|C|D|E|F] | |
ALPHA_NUM := [{ALPHA}|{NUM}] | |
// Start of file | |
name("LexiJ") // Generates file name: "LexiJ.java" | |
buffers(1) // Creates 1 buffer than can be used throughout the lexer. | |
#PIPE := "|" | |
#COLON_EQUAL := ":=" | |
#LEFT_BRACE := "{" | |
#RIGHT_BRACE := "}" | |
#LEFT_BRACKET := "[" | |
#RIGHT_BRACKET := "]" | |
#LEFT_PARENTHESES := "(" | |
#RIGHT_PARENTHESES := ")" | |
initial { | |
"|" := #PIPE | |
"[" := #LEFT_BRACKET | |
"]" := #RIGHT_BRACKET | |
"\\\\" := -> comment | |
// "\\\\" -> comment | |
({ALPHA}|_)+({ALPHA_NUM}|_)* := #NAMESPACE | |
// ([{ALPHA}|_])+([{ALPHA_NUM}|_])* := #NAMESPACE | |
{NUM} := #NUMBER; | |
"\"" := { | |
buffer[0].clear() | |
-> string | |
} | |
default := { | |
print("Fallthrough") | |
} | |
} | |
string { | |
"\"" := { | |
symbol(STRING, buffer[0]) | |
} | |
default := { | |
buffer[0].append(current()) | |
} | |
} | |
comment { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment