bashlex
bashlex copied to clipboard
Comments are not supported
Parsing a file with comments is not supported. For the following script:
# A comment
echo "A script with a comment"
The sample program (the one in the README) generates the following error:
Traceback (most recent call last):
File "sp.py", line 4, in <module>
parts = bashlex.parse(open(sys.argv[1]).read())
File "/usr/local/lib/python2.7/dist-packages/bashlex/parser.py", line 582, in parse
parts = [p.parse()]
File "/usr/local/lib/python2.7/dist-packages/bashlex/parser.py", line 641, in parse
tree = theparser.parse(lexer=self.tok, context=self)
File "/usr/local/lib/python2.7/dist-packages/bashlex/yacc.py", line 277, in parse
return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc,context)
File "/usr/local/lib/python2.7/dist-packages/bashlex/yacc.py", line 1079, in parseopt_notrack
tok = self.errorfunc(errtoken)
File "/usr/local/lib/python2.7/dist-packages/bashlex/parser.py", line 539, in p_error
p.lexer.source, p.lexpos)
bashlex.errors.ParsingError: unexpected token 'echo' (position 12)