Opened 10 years ago
Last modified 7 months ago
#11621 new enhancement
Preparser could accomodate multiline input and continuation lines
Reported by: | rbeezer | Owned by: | was |
---|---|---|---|
Priority: | minor | Milestone: | sage-6.4 |
Component: | user interface | Keywords: | |
Cc: | leif | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
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 (7)
comment:1 Changed 10 years ago by
- Cc leif added
comment:2 follow-up: ↓ 7 Changed 10 years ago by
comment:3 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:4 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:5 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:6 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:7 in reply to: ↑ 2 Changed 7 months ago by
Replying to 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.
That particular aspect is fixed by #31043.
Sage still chokes on pasted or typed input such as
T(r, t) = [r^2, t^2]
or
sage: T(r, t) = [r^2, ....: t^2]
or
sage: sage: T(r, t) = [r^2, ....: ....: t^2]
while it correctly handles:
sage: sage: sage: sage: 1 + 1
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.