more comments
This commit is contained in:
@@ -50,6 +50,7 @@ import java.util.ArrayList;
|
|||||||
new ComplexSymbolFactory.Location(yyline + 1,yycolumn + yylength()),
|
new ComplexSymbolFactory.Location(yyline + 1,yycolumn + yylength()),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void push(int indent){
|
private void push(int indent){
|
||||||
stack.add(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])*
|
Identifiers = (_|[a-z]|[A-Z])(_|[a-z]|[A-Z][0-9])*
|
||||||
Comments = #[^\r\n]*
|
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>{
|
<YYINITIAL>{
|
||||||
{WhiteSpace}
|
{WhiteSpace}
|
||||||
{
|
{
|
||||||
@@ -115,8 +124,10 @@ if True:
|
|||||||
if(top() > currIndent)
|
if(top() > currIndent)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
If the indentation of the line < indents current level should have,
|
If the indentation of the line is less than number of
|
||||||
keep dedenting until it reaches the right level.
|
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
|
It's like a loop, because we're not changing the state
|
||||||
and we rewinded the current character. So it will keep
|
and we rewinded the current character. So it will keep
|
||||||
going until top()<= currIndent and it will switch to
|
going until top()<= currIndent and it will switch to
|
||||||
@@ -126,12 +137,12 @@ if True:
|
|||||||
return symbol(ChocoPyTokens.DEDENT, currIndent);
|
return symbol(ChocoPyTokens.DEDENT, currIndent);
|
||||||
}
|
}
|
||||||
/*Otherwise, we will start dealing with the rest
|
/*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);
|
yystart(AFTER);
|
||||||
if(top()< currIndent)
|
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.
|
start a new level which will have `currIndent' spaces.
|
||||||
*/
|
*/
|
||||||
push(currIndent);
|
push(currIndent);
|
||||||
|
|||||||
Reference in New Issue
Block a user