Skip to content

Commit 92de23d

Browse files
author
Branislav Zahradník
committed
[parser] Formalize KW_FOR as a keyword starting new lexical scope
Tests covering this changes: - t/op/for-control-scope.t - t/op/for-over-scope.t * Motivation Normalize where new lexical context starts so every variant of for loop will start it at same position. Such normalization will later allow reduction of code currently duplicated. * Change description For statement already defined its own lexical scope in each its branch though in different places for each branch (using <*> as a marker): ``` for (<*> $control = 0; ...) for my <*> $cursor (...) for my <*> ($cursor_a, $cursor_b) (...) for $cursor (<*> ...) for my \ <*> $cursor (...) for \ my <*> $cursor (...) for \ $cursor (<*> ... ) for (<*> ...) ``` This change formalizes every branch to start with: ``` for <*> ... ``` * Technical details Lexical scope is started by non-terminal `remember` - empty with an action. Bison's LALR(1) grammar evaluates action before looking which terminal token follows, which means, that when `remember` occurs it must be either: - preceded by unique sequence of terminal tokens (approach used before) - be on same position for every possible branch (approach used by this change) As far as `KW_FOR` (as statement) always starts new lexical scope, it's possible to formalize it by starting it right after keyword, when `for` statement is identified.
1 parent 16b5acd commit 92de23d

File tree

4 files changed

+685
-684
lines changed

4 files changed

+685
-684
lines changed

perly.act

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

perly.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)