<READLINES>. {
yyless(0);
+ // This is the first line
if (!readline_indent) {
- readline_indent = current_indent;
- return T_INDENT;
+ // If indentation is above indent level,
+ // we are good to continue
+ if (current_indent > indent_level) {
+ readline_indent = current_indent;
+ return T_INDENT;
+
+ // If we found the same or less indentation we go back
+ // to the previous state and continue parsing there
+ } else {
+ yy_pop_state();
+ }
}
// <-- ?
- if (current_indent < readline_indent) {
+ else if (current_indent < readline_indent) {
readline_indent = 0;
yy_pop_state();
return T_OUTDENT;
- }
- yy_push_state(READLINE);
+ // The indentation stayed the same, read the next line
+ } else {
+ yy_push_state(READLINE);
+ }
}
<INDENT>\t { current_indent++; }