Moved from litterals to regular tokens for lisibility

This commit is contained in:
KikooDX 2020-05-08 15:42:36 +02:00
parent e5b0c6c44c
commit 07a5d92277
1 changed files with 30 additions and 5 deletions

View File

@ -26,28 +26,53 @@ reserved = {
'Goto': 'GOTO',
}
literals = '+-*/%(){}[]=,'
# List of token names
tokens = [
'PLUS',
'MINUS',
'TIMES',
'DIVIDE',
'MODULO',
'LPAREN',
'RPAREN',
'LCURBRA',
'RCURBRA',
'LSQRBRA',
'RSQRBRA',
'ASSIGN',
'COMMA',
'STRING',
'NUMBER',
'ISEQUAL',
'PLUSASSIGN',
'MINUSASSIGN',
'TIMESASSIGN',
'DIVASSIGN',
'MODASSIGN',
'DIVIDEASSIGN',
'MODULOASSIGN',
'NEWLINE',
'ID',
] + list(reserved.values())
# common regex
t_PLUS = r'\+'
t_MINUS = r'\-'
t_TIMES = r'\*'
t_DIVIDE = r'\/'
t_MODULO = r'\%'
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_LCURBRA = r'\{'
t_RCURBRA = r'\}'
t_LSQRBRA = r'\['
t_RSQRBRA = r'\]'
t_ASSIGN = r'\='
t_COMMA = r'\,'
t_ISEQUAL = r'=='
t_PLUSASSIGN = r'\+='
t_MINUSASSIGN = r'\-='
t_TIMESASSIGN = r'\*='
t_DIVASSIGN = r'/='
t_MODASSIGN = r'\%='
t_DIVIDEASSIGN = r'/='
t_MODULOASSIGN = r'\%='
# Comments
t_ignore_COMMENT = r'//.*'