Grammar is case sensitive?
See original GitHub issueI’m currently experimenting with lark
, and am attempting to run the following code:
from lark import Lark
grammar = '''
Stmt: "foo"
'''
parser = Lark(grammar, start='Stmt')
This results in the following exception:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\lark\parsers\lalr_parser.py", line 31, in get_action
return states_idx[state][key]
KeyError: 'RULE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tester.py", line 81, in <module>
parser = construct_parser(grammar, root)
File "tester.py", line 77, in construct_parser
return Lark(lark_grammar, start=root)
File "C:\Python35\lib\site-packages\lark\lark.py", line 143, in __init__
self.grammar = load_grammar(grammar, source)
File "C:\Python35\lib\site-packages\lark\load_grammar.py", line 537, in load_grammar
tree = self.simplify_tree.transform( self.parser.parse(grammar_text+'\n') )
File "C:\Python35\lib\site-packages\lark\parser_frontends.py", line 31, in parse
return self.parser.parse(tokens)
File "C:\Python35\lib\site-packages\lark\parsers\lalr_parser.py", line 60, in parse
action, arg = get_action(token.type)
File "C:\Python35\lib\site-packages\lark\parsers\lalr_parser.py", line 35, in get_action
raise UnexpectedToken(token, expected, seq, i)
lark.common.UnexpectedToken: Unexpected token Token(RULE, 'tmt') at line 2, column 6.
Expected: dict_keys(['_COLON'])
Context: <no context>
However, when I convert the phrase Stmt
to stmt
, the grammar starts working.
Is this behavior intentional? I didn’t see anything in the documentation about this (unless I missed it?) and as far as I’m aware, both grammars are valid EBNF grammars – the casing of the non-terminals and terminals should be irrelevant (at least, according to the EBNF specification on wikipedia).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Case-sensitive definition and meaning
In computing, if a written word such as a password is case-sensitive, it must be written in a particular form, for example using...
Read more >CASE-SENSITIVE definition | Cambridge English Dictionary
case -sensitive meaning: 1. If a computer program is case-sensitive, it can recognize if a letter is a capital or a small…. Learn...
Read more >case grammar
adj. relating to or denoting a case in some languages of nouns, pronouns, and adjectives, expressing location. ... n. (t… Case-sensitive , case-sensitive...
Read more >Case Sensitive: how english grammar got good eBook : ...
Case Sensitive : how english grammar got good - Kindle edition by Jacobs, Robert. Download it once and read it on your Kindle...
Read more >case-sensitive
case -sensitive meaning, definition, what is case-sensitive: a case-sensitive computer program recogn...: Learn more.
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
No. You can open an issue with that feature request.
If you mean the terminal values, then yes, of course. You do it by adding “i” to the end of the string or regexp.
Examples:
You can mix them too:
Does that answer you question?