Update styles

master
Sanjar Ahmadov 3 years ago
parent 75f4646161
commit 776e6001fd

@ -180,6 +180,8 @@ if True:
}
}
}
<AFTER> {
/* Delimiters. */
@ -191,19 +193,19 @@ if True:
{IntegerLiteral} { return symbol(ChocoPyTokens.NUMBER,
Integer.parseInt(yytext())); }
"\"" {yybegin(STR); str_l = yyline + 1; str_c = yycolumn + 1; currString = "";} //Start taking a string when see a "
"\"" { yybegin(STR); str_l = yyline + 1; str_c = yycolumn + 1; currString = ""; } //Start taking a string when see a "
"False" { return symbol(ChocoPyTokens.BOOL, false); }
"True" { return symbol(ChocoPyTokens.BOOL, true); }
"None" { return symbol(ChocoPyTokens.NONE); }
/*Keywords*/
"if" {return symbol(ChocoPyTokens.IF);}
"else" {return symbol(ChocoPyTokens.ELSE);}
"elif" {return symbol(ChocoPyTokens.ELIF);}
"while" {return symbol(ChocoPyTokens.WHILE);}
"class" {return symbol(ChocoPyTokens.CLASS);}
"def" {return symbol(ChocoPyTokens.DEF);}
"lambda" {return symbol(ChocoPyTokens.LAMBDA);}
"if" { return symbol(ChocoPyTokens.IF); }
"else" { return symbol(ChocoPyTokens.ELSE); }
"elif" { return symbol(ChocoPyTokens.ELIF); }
"while" { return symbol(ChocoPyTokens.WHILE); }
"class" { return symbol(ChocoPyTokens.CLASS); }
"def" { return symbol(ChocoPyTokens.DEF); }
"lambda" { return symbol(ChocoPyTokens.LAMBDA); }
"as" { return symbol(ChocoPyTokens.AS); }
"for" { return symbol(ChocoPyTokens.FOR); }
"global" { return symbol(ChocoPyTokens.GLOBAL); }
@ -253,21 +255,25 @@ if True:
/*Identifiers*/
{Identifiers} {return symbol(ChocoPyTokens.ID, yytext());}
{Identifiers} { return symbol(ChocoPyTokens.ID, yytext()); }
/* Whitespace. */
{WhiteSpace} { /* ignore */ }
/* Comment. */
{Comments} { /* ignore */ }
}
<STR>{
{StringLiteral} {currString += yytext();}
{StringLiteral} { currString += yytext(); }
\\$ { /*'\' at the end of line, do nothing.*/ }
"\"" {yybegin(AFTER); return symbolFactory.newSymbol(ChocoPyTokens.terminalNames[ChocoPyTokens.STRING], ChocoPyTokens.STRING,
"\"" { yybegin(AFTER); return symbolFactory.newSymbol(ChocoPyTokens.terminalNames[ChocoPyTokens.STRING], ChocoPyTokens.STRING,
new ComplexSymbolFactory.Location(str_l, str_c),
new ComplexSymbolFactory.Location(yyline + 1,yycolumn + yylength()),
currString);} // accepted a ", return to AFTER state
currString); } // accepted a ", return to AFTER state
}
<<EOF>> { if(!stack.isEmpty()){ return symbol(ChocoPyTokens.DEDENT, pop());} return symbol(ChocoPyTokens.EOF);}
<<EOF>> { if(!stack.isEmpty()){ return symbol(ChocoPyTokens.DEDENT, pop());} return symbol(ChocoPyTokens.EOF); }
/* Error fallback. */
[^] { return symbol(ChocoPyTokens.UNRECOGNIZED); }

Loading…
Cancel
Save