forked from google/starlark-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax: improve REPL parsing (google#98)
Previously, the REPL used a heuristic: it would consume a single line and attempt to parse it; if that failed, it would consume lines up to a blank line then parse the whole as a file. This was suboptimal for various reasons: it failed to parse lines ending with an unfinished multi-line string literal, for example, and it would prematurely stop reading even while parentheses were open. This change integrates the REPL with the scanner and parser (as Python does). The REPL invokes a new parser entry point, ParseCompoundStmt, that consumes only enough input to parse a compound statement, defined as (a) blank line, (b) a semicolon-separated list of simple statements all on one line, or (c) a complex statement such as def, if or for. If the 'src' value provided to the scanner is a function of type func() ([]byte, error), then the scanner will call it each time it runs out of input. Fixes google#81
- Loading branch information
Showing
7 changed files
with
347 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.