line number on rule
See original GitHub issueWhat is your question?
I have a grammar like this one, for JSON:
?start: value
?value: object
| array
| string
| SIGNED_NUMBER -> number
| "true" -> true
| "false" -> false
| "null" -> null
array : "[" [value ("," value)*] "]"
object : "{" [pair ("," pair)*] "}"
pair : string ":" value
string : ESCAPED_STRING
%import common.ESCAPED_STRING
%import common.SIGNED_NUMBER
%import common.WS
%ignore WS
if I do this on a transformer:
@staticmethod
@lark.v_args(inline=True)
def string(token: lark.Token) -> frozendict:
return frozendict({
'column': token.column,
'item': ast.literal_eval(token),
'line': token.line
})
I can get line and column numbers
however, in array, or object rules the tree.meta.line
(or tree.line
) attributes are empty (and raise an error)
@staticmethod
@lark.v_args(tree=True)
def array(tree: lark.Tree) -> frozendict:
I would like to be able to get the line number of such properties
Thanks in advance!
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
NUMBER LINE RULES Flashcards - Cram.com
ON A NUMBER LINE THE NEGATIVE NUMBER CLOSES TO THE ZERO IS THE LARGEST NUMBER WICH IS -1. COMPARISON SIGNS 5>3 FIVE IS...
Read more >Line numbers - Typography for Lawyers
In the text box, type your line numbers. Use a hard line break between each number, not a carriage return, so the whole...
Read more >Add rules (lines) to separate text in Numbers on Mac
Select the text where you want to add a rule. In the Format sidebar, click the Text tab, then click the Layout button...
Read more >Create a Rule to Generate a Number Pattern
Videos, solutions, worksheets, and examples to help grade 5 students learn how to create a rule to generate a number pattern, and plot...
Read more >Line Number Definition | Law Insider
Line Number means the alpha numeric digits We allocated to You upon Your subscription to Our Services. Sample 1Sample 2Sample 3.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@erezsh Slight correction: Just having an
meta
attribute actually doesn’t work, it needs to be an instance of either Token or Tree. It might be worth considering to change this though to support custom AST generation with meta information.Maybe also move everything in Token into a meta attribute.
You’re right. It has to subclass one of them to work.