xonsh multiline with coconut: SyntaxError
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
```xsh
xontrib load coconut
echo a \
b
```
```xsh
Traceback (most recent call last):
File "/Users/pc/Documents/git/xonsh/xonsh/shells/ptk_shell/__init__.py", line 459, in _push
code = self.execer.compile(
deindent(src),
...<3 lines>...
compile_empty_tree=False,
)
File "/Users/pc/Documents/git/xonsh/xonsh/execer.py", line 147, in compile
tree = self.parse(
input,
...<4 lines>...
user_names=user_names,
)
File "/Users/pc/Documents/git/xonsh/xonsh/execer.py", line 90, in parse
tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pc/Documents/git/xonsh/xonsh/execer.py", line 383, in _parse_ctx_free
return _try_parse(input, greedy=True)
File "/Users/pc/Documents/git/xonsh/xonsh/execer.py", line 262, in _try_parse
raise original_error from None
File "/Users/pc/Documents/git/xonsh/xonsh/execer.py", line 265, in _try_parse
tree = self.parser.parse(
input,
...<2 lines>...
debug_level=(self.debug_level >= 2),
)
File "/Users/pc/micromamba/envs/xonsh-dev/lib/python3.13/site-packages/coconut/integrations.py", line 145, in new_parse
return parser.__class__.parse(parser, code, mode=mode, *args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/base.py", line 728, in parse
tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/ply/yacc.py", line 335, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/ply/yacc.py", line 1203, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/ply/yacc.py", line 194, in call_errorfunc
r = errorfunc(token)
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/base.py", line 4097, in p_error
self._parse_error(msg, self.currloc(lineno=p.lineno, column=p.lexpos))
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/base.py", line 865, in _parse_error
raise_parse_error(msg, loc, self._source, self.lines)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pc/Documents/git/xonsh/xonsh/parsers/base.py", line 429, in raise_parse_error
raise err
File "", line 2
b] #1: ![echo a\
^^^^^^^^^^^^^^^^^
SyntaxError: code: b
```
Contributor guide
Research direction
Reproduce the xonsh example using `xontrib load coconut` and the multiline `echo` command. Start by tracing the parser integration at `coconut/integrations.py`, alongside the parse path shown through `xonsh/execer.py`; done means this input no longer raises the reported SyntaxError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100