Ticket #11621 (new enhancement)
Preparser could accomodate multiline input and continuation lines
| Reported by: | rbeezer | Owned by: | was |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.10 |
| Component: | user interface | Keywords: | |
| Cc: | leif | Work issues: | |
| Report Upstream: | N/A | Reviewers: | |
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
It would be an improvement to have the preparser recognize when an input line follows Python conventions for multiline input via Python's rules for continuation lines and mechanisms for indicating continuation lines in doctests, etc (namely "..." and perhaps soon "....:"). If you paste the following into a command-line session:
T(r, t) = [r^2, ... t^2]
the result is:
sage: T(r, t) = [r^2,
------------------------------------------------------------
File "<ipython console>", line 1
__tmp__=var("r,t"); T = symbolic_expression([r**Integer(2),).function(r,t)
^
SyntaxError: invalid syntax
sage: ... t^2]
------------------------------------------------------------
File "<ipython console>", line 1
... t**Integer(2)]
^
SyntaxError: invalid syntax
Some discussion at
http://groups.google.com/group/sage-devel/browse_thread/thread/81a3cce1ebfefd0e
See related #10458.
Change History
comment:2 Changed 22 months ago by jason
Notice also this inconsistency dealing with multiline statements starting with comments, caused by an early-abort statement in the preparser:
sage: preparse("""x^2\n# test\nx^2""")
'x**Integer(2)\n# test\nx**Integer(2)'
sage: preparse("""# test\nx^2""")
'# test\nx^2'
Note that if the string starts with a comment, everything is ignored after the comment. However, if the statement does not start with a comment, things are preparsed even after the comment.
