Skip to content

Conversation

@rocky
Copy link
Member

@rocky rocky commented May 29, 2025

Tracks changes in scanner to handle escape sequences more correctly and to handle escaped boxing operators more properly.

  • .github/workflows: CI testing needs to be done with revise-escape-sequence-scanning branch
  • parser.py: next() needs to catch at least escape sequence errors. (Maybe more?)
  • test_parser.py: we now give a more specific "NamedCharacterSyntaxError" error

Comment out self.check("x \\ny", "Times[x, y]") test until we understand what the right behavior is. (Next time we'll document the test better.)

rocky added 3 commits May 29, 2025 12:50
.github/workflows: CI testing needs to be doine with revise-escape-sequence-scanning branch

parser.py: next() needs to catch at least escape sequence errors. (Maybe
more?)

test_parser.py: we now give a more specific "NamedCharacterSyntaxError"
error

Comment out self.check("x \\\ny", "Times[x, y]") test until we
understand what the right behavior is. (Next time we'll document the
test better.)
TranslateError, TranslateErrorNew, ScanError are now all ScannerError
Use more direct and simpler error class name that is is more like its
other subclassed errors.

def p_String(self, token: Token) -> String:
result = String(unescape_string(token.text))
result = String(token.text[1:-1])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoiding "unescape_string" probably addresses the warnings in testing we've been getting about invalid Python escape sequences.

I think the situation previously was that the scanner was relying on unescape_string to convert some escape strings rather than handed these in the scanner.

self.check("x \\\ny", "Times[x, y]")

## TODO see what this should do and why
## self.check("x \\\ny", "Times[x, y]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be useful: in the console, WMA:


Syntax::sntxf: "x " cannot be followed by "\n y".


In[2]:= x *\n y                                                                 

Syntax::sntxf: "x *" cannot be followed by "\n y".


In[3]:= x *                                                                     
y                                                                               

Out[3]= x y

@rocky rocky merged commit 8485c2f into master Jun 3, 2025
14 checks passed
@rocky rocky deleted the revise-escape-sequence-scanning branch June 3, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants