-
Notifications
You must be signed in to change notification settings - Fork 3
Parse multi-character operators. #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/arx/lexer.py
def _parse_operator(self) -> Token:
"""Parse multi-character operators."""
location = copy.copy(self.lex_loc) # shallow copy is sufficient
op = self.last_char
self.last_char = self.advance()
two_char_ops = {
'==': 'eq', '!=': 'ne', '>=': 'ge', '<=': 'le',
'->': 'arrow', '//': 'comment'
}
next_ch = self.last_char if isinstance(self.last_char, str) else ''
if next_ch and op + next_ch in two_char_ops:
full_op = op + next_ch
if full_op == '//':
# skip until end of line
while self.last_char not in ('\n', '', None):
self.last_char = self.advance()
if self.last_char == '\n':
self.last_char = self.advance()
return self.get_token()
self.last_char = self.advance()
return Token(kind=TokenKind.operator, value=two_char_ops[full_op], location=location)
return Token(kind=TokenKind.operator, value=op, location=location)
|
251d1d5 to
11f95d9
Compare
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/arx/lexer.py
|
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/arx/lexer.py
|
Pull Request description
Add operator and Multi-character Token Support
#21How to test these changes
...Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
complexity.
Additional information
Reviewer's checklist
Copy and paste this template for your review's note: