### KeyWords and atomic strings
DEF             := 'def', ts
COLON           := ':', ts
OPENPAREN       := "(", ts
CLOSEPAREN      := ")", ts
EQUALSIGN       := "=", ts
COMMA           := ",", ts
OPENBRACKET     := "[", ts
CLOSEBRACKET    := "]", ts
OPENBRACE       := "{", ts
CLOSEBRACE      := "}", ts
ASTERISK        := "*", ts
PRINT           := "print", ts
DEL             := "del", ts
PASS            := "pass", ts
BREAK           := "break", ts
CONTINUE        := "continue", ts
RETURN          := "return", ts
RAISE           := "raise", ts
IMPORT          := "import", ts
GLOBAL          := "global", ts
FROM            := "from", ts
DOT             := ".", ts

EXEC            := "exec", ts
EVAL            := "eval", ts
ASSERT          := "assert", ts
EXCEPT          := "except", ts
OR              := "or", ts
AND             := "and", ts
NOT             := "not", ts
IS              := "is", ts

BAR             := '|',ts
HAT             := '^',ts
AND_SYMBOL      := '&',ts
SHIFT           := ('<<'/'>>'),ts
ARITH           := ('+'/'-'),ts
TERM            := ('*'/'/'/'%'), ts
FACTOR          := ('+'/'-'/'~'), ts
BACKQUOTE       := '`',ts
LAMBDA          := 'lambda',ts
CLASS           := 'class', ts

NEWLINE         := '\n', ts

### Single-group comparison operator
comp_op         := ('<'/'>'/'=='/'>='/'<='/'<>'/'!='/'in'/('not',ts, 'in')/'is'/('is',ts,'not')),ts

### Higher level constructions


# build number from various cases... Copied from tokenize.py
Hexnumber       := '0',[xX],[\da-fA-F]*,[lL]?
Octnumber       := '0',[0-7]*,[lL]?
Decnumber       := [1-9][0-9]*[lL]?
Intnumber       := Hexnumber/Octnumber/Decnumber
Exponent        := [eE],[-+]?,[0-9]+
Pointfloat      := ([0-9]+,'.',[0-9]*)/('.',[0-9]+), Exponent?
Expfloat        := [1-9],[0-9]*, Exponent
Floatnumber     := Pointfloat/Expfloat
Imagnumber      := ('0',[jJ])/([1-9],[0-9]*,[jJ])/(Floatnumber,[jJ])

NUMBER          := (Imagnumber/Floatnumber/Intnumber), ts


# ts and Ignorables...
ts              := [ \f\t]*
Comment         := '#',[^\r\n]*
Ignore          := (ts, ('\r'/'\n'))/ts/Comment?

# Identifier
NAME            := [a-zA-Z_],[a-zA-Z_0-9]*


# Strings...
DBLSTRING       := '"',(-[\134"]+/ESCAPEDCHAR)*,'"'
SNGLSTRING      := "'",(-[\134']+/ESCAPEDCHAR)*,"'"
TRPLSNGLSTRING  := "'''",(-[\134']+/("'",-"''")/ESCAPEDCHAR)*,"'''"
TRPLDBLSTRING   := '"""',(-[\134"]+/('"',-'""')/ESCAPEDCHAR)*,'"""'
ESCAPEDCHAR         := '\134',(OCTALESCAPEDCHAR/ANYCHAR)
OCTALESCAPEDCHAR    :=  [0-7],[0-7]?,[0-7]?
ANYCHAR             :=  [\000-\377]

STRING          := (DBLSTRING/SNGLSTRING/TRPLSNGLSTRING/TRPLDBLSTRING)




