Skip to content

Commit

Permalink
Fixed incorrect lexing of backtick in Get. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmenon committed Apr 29, 2016
1 parent 409ee87 commit de8ede8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mathematica/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Regex:
IDENTIFIER = r'[a-zA-Z\$][a-zA-Z0-9\$]*'
NAMED_CHARACTER = r'\\[{identifier}]'.format(identifier=IDENTIFIER)
SYMBOLS = (r'[`]?({identifier}|{named_character})(`({identifier}|{named_character}))*'
SYMBOLS = (r'[`]?({identifier}|{named_character})(`({identifier}|{named_character}))*[`]?'
.format(identifier=IDENTIFIER, named_character=NAMED_CHARACTER))
INTEGER = r'[0-9]+'
FLOAT = r'({integer})?\.[0-9]+|{integer}\.'.format(integer=INTEGER)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 rsmenon
# Licensed under the MIT License (https://opensource.org/licenses/MIT)

Expand Down
14 changes: 14 additions & 0 deletions tests/test_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ def test_symbols(self):
expected = [[(MToken.SYMBOL, sym)] for sym in code]
self.verify_all(code, expected)

def test_get(self):
code = ['<<Foo`', '<<Foo`Bar`']
expected = [
[
(MToken.OPERATOR, '<<'),
(MToken.SYMBOL, 'Foo`'),
],
[
(MToken.OPERATOR, '<<'),
(MToken.SYMBOL, 'Foo`Bar`'),
]
]
self.verify_all(code, expected)

def test_builtins(self):
code = list(mma.SYSTEM_SYMBOLS)
expected = [[(MToken.BUILTIN, sym)] for sym in code]
Expand Down

0 comments on commit de8ede8

Please sign in to comment.