diff options
| author | John Estabrook <jestabro@vyos.io> | 2022-04-27 14:35:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 14:35:59 -0500 |
| commit | f000b3ff2d4641ab19c34661f07caa99d8a11121 (patch) | |
| tree | 1907c5e02b635c426a43904f85358c56406a8546 /src/parser.ml | |
| parent | 6725043051d20f0211da184dd0aab77472873fcf (diff) | |
| parent | 3f86b8278389ae9978cbce1d45be6f03ed29035a (diff) | |
| download | vyos1x-config-f000b3ff2d4641ab19c34661f07caa99d8a11121.tar.gz vyos1x-config-f000b3ff2d4641ab19c34661f07caa99d8a11121.zip | |
Merge pull request #6 from dmbaturin/master
T4334: make the lexer reentrant by passing state around instead of using a shared mutable reference
Diffstat (limited to 'src/parser.ml')
| -rw-r--r-- | src/parser.ml | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/parser.ml b/src/parser.ml index b334a20..f659b34 100644 --- a/src/parser.ml +++ b/src/parser.ml @@ -3,18 +3,18 @@ open Lexing module I = Vyos1x_parser.MenhirInterpreter -let rec parse lexbuf (checkpoint : Config_tree.t I.checkpoint) = +let rec parse vy_inside_node lexbuf (checkpoint : Config_tree.t I.checkpoint) = match checkpoint with | I.InputNeeded _env -> - let token = Vyos1x_lexer.token lexbuf in + let vy_inside_node, token = Vyos1x_lexer.token vy_inside_node lexbuf in let startp = lexbuf.lex_start_p and endp = lexbuf.lex_curr_p in let checkpoint = I.offer checkpoint (token, startp, endp) in - parse lexbuf checkpoint + parse vy_inside_node lexbuf checkpoint | I.Shifting _ | I.AboutToReduce _ -> let checkpoint = I.resume checkpoint in - parse lexbuf checkpoint + parse vy_inside_node lexbuf checkpoint | I.HandlingError _env -> let line, pos = Util.get_lexing_position lexbuf in raise (Syntax_error (Some (line, pos), "Invalid syntax.")) @@ -23,5 +23,6 @@ let rec parse lexbuf (checkpoint : Config_tree.t I.checkpoint) = raise (Syntax_error (None, "invalid syntax (parser rejected the input)")) let from_string s = + let vy_inside_node = false in let lexbuf = Lexing.from_string s in - parse lexbuf (Vyos1x_parser.Incremental.config lexbuf.lex_curr_p) + parse vy_inside_node lexbuf (Vyos1x_parser.Incremental.config lexbuf.lex_curr_p) |
