File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,20 @@ can be used and manipulated as below.
401401 </howto/lexing/>` and want subsequent parsing of the token stream to be
402402 able to report original positions in error messages etc.
403403
404+ .. method :: span()
405+
406+ Returns a parser that augments the initial parser's result with a :class: `SourceSpan `
407+ containing information about where that parser started and stopped within the
408+ source data. The new value is a tuple:
409+
410+ .. code :: python
411+
412+ (source_span, original_value)
413+
414+ This enables reporting of custom errors involving source locations, such as when
415+ using parsy as a :doc: `lexer</howto/lexing/> ` or when building a syntax tree that will be
416+ further analyzed.
417+
404418.. _operators :
405419
406420Parser operators
@@ -607,3 +621,9 @@ Auxiliary data structures
607621 .. method:: __init__ (data, [source=None ])
608622
609623 Wraps the data into a stream, possibly equipping it with a source.
624+
625+ .. class :: SourceSpan
626+
627+ Identifies a span of material from the data being parsed by its start row and column and its end
628+ row and column. If the data stream was equipped with a source, that value is also available in
629+ this object .
You can’t perform that action at this time.
0 commit comments