bashlex
bashlex copied to clipboard
Python parser for bash
for the code as following ```python code = '''cat
Signed-off-by: Nick Diego Yamane
I'm using `bashlex` to parse build log files to extract compilation commands. I've just realized that when single line strings with comments are passed to the parser, it fails raising...
Allows to parse whole files. The idea is that I force-reduce on inputunit -> NEWLINE rule and accept by creating a dummy newline node that only retains position (needed for...
I'm seeing a strange bug with variable assignments ```python >>> list(bashlex.split("PATH=\"$PATH:/usr/local/bin/\"")) ['PATH="$PATH:/usr/local/bin/"'] ^ ^ # note the quote marks / >>> list(bashlex.split("PATH2=\"$PATH:/usr/local/bin/\"")) ['PATH2=$PATH:/usr/local/bin/'] # the quote marks are gone! ```...
Quoting [Bash Guide for Beginners :: 10.2.1. Creating arrays](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_02.html): > Array variables may also be created using compound assignments in this format: > > ARRAY=(value1 value2 ... valueN) I have...
I was just grazing through the code and found that lot of class name in [ast.py](https://github.com/idank/bashlex/blob/master/bashlex/ast.py) is in small letters. In [PEP8](https://www.python.org/dev/peps/pep-0008/#class-names), class names have CapWords. Just wanted to ask...
bashlex.errors.ParsingError: unexpected token '(' (position 7) May be caused by the fact that '!' is interpreted as WORD instead of BANG.
Parsing a file with comments is not supported. For the following script: ``` sh # A comment echo "A script with a comment" ``` The sample program (the one in...
Parsing a file with new lines between statements is not supported. For the following script: ``` sh echo "Line 1" echo "Line 3" ``` The sample program (the one in...