I have two questions about grammar #887
Unanswered
Pete-mathpresso
asked this question in
Q&A
Replies: 1 comment 6 replies
-
If you were using Earley, you could even write
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What should I do if I don't want to ignore some of the grammar in grammar and some of it? In the Lark grammar, %ignore " " is used to control the spaces in all rules and terminal definitions, but I want to control only some of them.
For example, when you create a grammar that takes and parses a multiplication with latex-form of alphabet, integer and decimal numbers do not want spaces on both sides of the point, but I want to ignore them otherwise. All I can think of is using regular expressions. I wonder if there is a module that can be provided by the Lark library, such as the 'Combine' module provided by Pyparsing. (It's 1st Question)
[2nd Question]
I want to implement a grammar that parses integer or decimal characters, but I am having difficulty using or grammar.How do we deal with this?
I wrote like this,
grammar =
r"""
expr : integer | decimal_default
"""
parser = Lark(grammar, parser='lalr', start='expr')
test_text = r'3.5'
test_result = parser.parse(test_text)
result = parser.parse(test_text)
print('result : ', result)
But there is a bug report like that,
Beta Was this translation helpful? Give feedback.
All reactions