Skip to content

Commit 732f63f

Browse files
authored
Merge pull request #232 from Pat-Lafon/main
Richer Source Positions
2 parents 2002252 + 6ce9589 commit 732f63f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/lang/syntax.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ It also has the optional `args`, `funcs`, and `labels` fields.
124124
Source Positions
125125
----------------
126126

127-
Any syntax object may optionally have a `pos` field to reflect a source position:
127+
Any syntax object may optionally have position fields to reflect a source position:
128128

129-
{ ..., "pos": {"row": <int>, "col": <int>} }
129+
{ ..., "pos": {"row": <int>, "col": <int>},
130+
"pos_end": {"row": <int>, "col": <int>}?,
131+
"src": "<string>"? }
130132

131-
The `pos` object has two keys: `row` (the line number) and `col` (the column number within the line).
133+
The `pos` and `pos_end` objects have two keys: `row` (the line number) and `col` (the column number within the line). The `src` object can optionally provide the absolute path to a file which is referenced to by the source position.
134+
If `pos_end` is provided, it must be equal to or greater than `pos`.
132135
Front-end compilers that generate Bril code may add this information to help with debugging.
133136
The [text format parser](../tools/text.md), for example, can optionally add source positions.
134137
However, tools can't require positions to exist, to consistently exist or not on all syntax objects in a program, or to follow any particular rules.

0 commit comments

Comments
 (0)