more comments

master
bill 3 years ago
parent 62330bd237
commit d5097498b7

@ -50,6 +50,7 @@ import java.util.ArrayList;
new ComplexSymbolFactory.Location(yyline + 1,yycolumn + yylength()),
value);
}
private void push(int indent){
stack.add(indent);
}
@ -73,7 +74,15 @@ StringLiteral = ([^\"\\]|(\\\")|(\\t)|(\\r)|(\\n)|(\\\\))* // \n, \r, \t, \\, \"
Identifiers = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z][0-9])*
Comments = #[^\r\n]*
%%
//YYINITIAL state is where we're dealing with indentations.
//We will set the state to YYINITIAL when starting a
//new line unless this line is within a string, e.g.:
/*
"this is \
a string across \
multiple lines\
"
*/
<YYINITIAL>{
{WhiteSpace}
{
@ -115,8 +124,10 @@ if True:
if(top() > currIndent)
{
/*
If the indentation of the line < indents current level should have,
keep dedenting until it reaches the right level.
If the indentation of the line is less than number of
indents current level should have,
keep dedenting until it reaches the level with the same
number of indents.
It's like a loop, because we're not changing the state
and we rewinded the current character. So it will keep
going until top()<= currIndent and it will switch to
@ -126,12 +137,12 @@ if True:
return symbol(ChocoPyTokens.DEDENT, currIndent);
}
/*Otherwise, we will start dealing with the rest
of the line after indentation in from the next token.*/
of the line after indentation in AFTER state. */
yystart(AFTER);
if(top()< currIndent)
{
/*
If current indentation > indents current level should have,
If current indentation is more than indents current level should have,
start a new level which will have `currIndent' spaces.
*/
push(currIndent);

Loading…
Cancel
Save