-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing fails for if [[ -f "../build/tmp/dklm/klm_exports.h" ]] #43
Comments
In a Python interactive session with Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bashlex
>>> bashlex.parse('if [[ -f "../build/tmp/dklm/klm_exports.h" ]]')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 610, in parse
parts = [p.parse()]
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 691, in parse
tree = theparser.parse(lexer=self.tok, context=self)
File "/home/user/.local/lib/python3.10/site-packages/bashlex/yacc.py", line 537, in parse
tok = self.errorfunc(errtoken)
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 548, in p_error
raise errors.ParsingError('unexpected token %r' % p.value,
bashlex.errors.ParsingError: unexpected token '-f' (position 6) |
Looks like there is a bug with the expected states when parsing COND_CMD tokens. The only valid next token is "COND_CMD" from "COND_START", but the type being returned is "WORD". Even expressions like There are parserflags CONDCMD and CONDEXPR defined but it isn't clear what the intent or difference is between them. https://github.com/idank/bashlex/blob/master/bashlex/tokenizer.py#L563-L564 https://github.com/idank/bashlex/blob/master/bashlex/tokenizer.py#L1159-L1160 |
The only way to understand is by looking at the C code side by side. |
Parsing fails for
if [[ -f "../build/tmp/dklm/klm_exports.h" ]]
The text was updated successfully, but these errors were encountered: