diff options
author | Sunil Shetye | 2018-06-10 19:52:34 +0530 |
---|---|---|
committer | Sunil Shetye | 2018-06-10 19:52:34 +0530 |
commit | 89187d41b6688f522f09ad59a8e223c82b8af846 (patch) | |
tree | b8dbf3dd38c942c6ae0b24117f9ef9a9d3f0c86a /sci2jslex.py | |
parent | 99d1f50e613cf07d83ca714e075e1d00aa7bd38d (diff) | |
download | sci2js-89187d41b6688f522f09ad59a8e223c82b8af846.tar.gz sci2js-89187d41b6688f522f09ad59a8e223c82b8af846.tar.bz2 sci2js-89187d41b6688f522f09ad59a8e223c82b8af846.zip |
support transpose operator
distinguish it from string in quotes
Diffstat (limited to 'sci2jslex.py')
-rwxr-xr-x | sci2jslex.py | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/sci2jslex.py b/sci2jslex.py index e2b28d93..cb14511a 100755 --- a/sci2jslex.py +++ b/sci2jslex.py @@ -83,12 +83,47 @@ def t_EOL(t): t.state = 'EOL' return t -t_NUMBER = r'-?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?' -t_LASTINDEX = r'\$' -t_DOT = r'\.' -t_OPERATOR = r'[+\-*/^\\]' -t_COMPARISON = r'<>|[<>~=]=|[<>]' -t_COMMA = r',' +def t_NUMBER(t): + r'-?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?' + global afterarray + afterarray = False + t.state = 'NUMBER' + return t + +def t_LASTINDEX(t): + r'\$' + global afterarray + afterarray = False + t.state = 'LASTINDEX' + return t + +def t_DOT(t): + r'\.' + global afterarray + afterarray = False + t.state = 'DOT' + return t + +def t_OPERATOR(t): + r'[+\-*/^\\]' + global afterarray + afterarray = False + t.state = 'OPERATOR' + return t + +def t_COMPARISON(t): + r'<>|[<>~=]=|[<>]' + global afterarray + afterarray = False + t.state = 'COMPARISON' + return t + +def t_COMMA(t): + r',' + global afterarray + afterarray = False + t.state = 'COMMA' + return t def t_OPENSQBRACKET(t): r'\[' |