|
|
|
@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|
|
|
|
%unicode
|
|
|
|
|
%line
|
|
|
|
|
%column
|
|
|
|
|
%states AFTER
|
|
|
|
|
%states AFTER, STR
|
|
|
|
|
%class ChocoPyLexer
|
|
|
|
|
%public
|
|
|
|
|
|
|
|
|
@ -33,6 +33,7 @@ import java.util.ArrayList;
|
|
|
|
|
/** Producer of token-related values for the parser. */
|
|
|
|
|
final ComplexSymbolFactory symbolFactory = new ComplexSymbolFactory();
|
|
|
|
|
private int currIndent = 0;
|
|
|
|
|
private int currString = "";
|
|
|
|
|
private ArrayList<Integer> stack = new ArrayList<Integer>(20);
|
|
|
|
|
/** Return a terminal symbol of syntactic category TYPE and no
|
|
|
|
|
* semantic value at the current source location. */
|
|
|
|
@ -67,7 +68,7 @@ WhiteSpace = [ \t]
|
|
|
|
|
LineBreak = \r|\n|\r\n
|
|
|
|
|
|
|
|
|
|
IntegerLiteral = 0|[1-9][0-9]*
|
|
|
|
|
StringLiteral = \"([^\"\\]|(\\\")|(\\t)|(\\r)|(\\n)|(\\\\))*\"
|
|
|
|
|
StringLiteral = ([^\"\\]|(\\\")|(\\t)|(\\r)|(\\n)|(\\\\))*
|
|
|
|
|
Names = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z])*
|
|
|
|
|
Comments = #[^\r\n]*
|
|
|
|
|
%%
|
|
|
|
@ -112,7 +113,8 @@ Comments = #[^\r\n]*
|
|
|
|
|
/* Literals. */
|
|
|
|
|
{IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER,
|
|
|
|
|
Integer.parseInt(yytext())); }
|
|
|
|
|
{StringLiteral} { return symbol(ChocoPyTokens.STRING, yytext());}
|
|
|
|
|
// {StringLiteral} { return symbol(ChocoPyTokens.STRING, yytext());}
|
|
|
|
|
"\"" {yystart(STR); currString = "";}
|
|
|
|
|
"False" { return symbol(ChocoPyTokens.BOOL, false); }
|
|
|
|
|
"True" { return symbol(ChocoPyTokens.BOOL, true); }
|
|
|
|
|
"None" { return symbol(ChocoPyTokens.NONE); }
|
|
|
|
@ -180,7 +182,10 @@ Comments = #[^\r\n]*
|
|
|
|
|
/* Comment. */
|
|
|
|
|
{Comments} { /* ignore */ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<STR>{
|
|
|
|
|
{StringLiteral} {currString+=yytext();}
|
|
|
|
|
"\"" {yybegin(AFTER); return symbol(ChocoPyTokens.STRING, currString);}
|
|
|
|
|
}
|
|
|
|
|
<<EOF>> { return symbol(ChocoPyTokens.EOF); }
|
|
|
|
|
|
|
|
|
|
/* Error fallback. */
|
|
|
|
|