bashlex icon indicating copy to clipboard operation
bashlex copied to clipboard

space at the end of line - parse error

Open bAndie91 opened this issue 4 years ago • 3 comments

>>> bashlex.parse('cmd1\ncmd2 \ncmd3\n')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bashlex/parser.py", line 614, in parse
    part = _parser(s[index:], strictmode=strictmode).parse()
  File "bashlex/parser.py", line 682, in parse
    tree = theparser.parse(lexer=self.tok, context=self)
  File "bashlex/yacc.py", line 277, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc,context)
  File "bashlex/yacc.py", line 1079, in parseopt_notrack
    tok = self.errorfunc(errtoken)
  File "bashlex/parser.py", line 539, in p_error
    p.lexer.source, p.lexpos)
bashlex.errors.ParsingError: unexpected token 'cmd3' (position 1)

bAndie91 avatar Apr 24 '20 09:04 bAndie91

I was unable to reproduce this issue using version 0.18.

samlikins avatar May 17 '23 11:05 samlikins

Hey, thanks for going over these issues. It would be extra awesome if you could add a test case that shows these parse correctly.

idank avatar May 17 '23 11:05 idank

@idank: Absolutely!

In a Python interactive session (using bashlex v0.18):

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('cmd1\ncmd2 \ncmd3\n')
[CommandNode(parts=[WordNode(parts=[] pos=(0, 4) word='cmd1')] pos=(0, 4)), CommandNode(parts=[WordNode(parts=[] pos=(5, 9) word='cmd2')] pos=(5, 9)), CommandNode(parts=[WordNode(parts=[] pos=(11, 15) word='cmd3')] pos=(11, 15))]

samlikins avatar May 17 '23 12:05 samlikins