Skip to content

Commit

Permalink
Added positional offsets to each YangStatement
Browse files Browse the repository at this point in the history
This allows the parse results to be used in applications like syntax highlighting / code
folding / etc.
  • Loading branch information
Jason Larke committed Dec 16, 2019
1 parent 9cf1811 commit 696914b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/yang-parser.litcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,22 @@ The result of the `statement` parser is an initialized `YangStatement`
object. If no argument is present, the object's `arg` property is set
to `false`.

statement = keyword.bind (kw) ->
rawStatement = keyword.bind (kw) ->
(sep.bind -> argument).option(false).bind (arg) ->
strict = true if kw[1] is 'yang-version' and arg is '1.1'
optSep.bind -> semiOrBlock.bind (sst) ->
P.unit new YangStatement kw[0], kw[1], arg, sst
statement = new P (offset) ->
[stmt, end] = rawStatement.pf offset
if stmt is null
[null, end]
else
stmt.sp = offset
stmt.ep = end
[stmt, end]
A statement block is a sequence of statements enclosed in
braces. Whitespace or comments are permitted before or after any
statement in the block.
Expand Down

0 comments on commit 696914b

Please sign in to comment.