From 89187d41b6688f522f09ad59a8e223c82b8af846 Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Sun, 10 Jun 2018 19:52:34 +0530 Subject: support transpose operator distinguish it from string in quotes --- sci2jslex.py | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'sci2jslex.py') 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'\[' -- cgit