Support all tasm operators

note that tasm follows strict l-to-r evaluation, but admonishes programmers
to fully parenthesize calculations for compatibility with other
assemblers.
This commit is contained in:
Jeff Epler 2014-08-10 21:36:12 -05:00
parent 5bf5ab42a8
commit 2ee646eb86

View file

@ -101,12 +101,14 @@ Colon = Literal(":")
Label = Identifier.copy().setParseAction(
lambda s, loc, toks: toks[0]).setResultsName("label")
def Literals(*args): return Or(Literal(a) for a in args)
InfixOperator = Literals(*'+ - * / % << >> == = != <= >= < > & | ^'.split())
Expression = Forward().setName("expression")
Value = Number | Identifier | ('(' + Expression + ')')
Product = Value + (Word('*/', max=1) + Value) * STAR
Sum = Product + (Word('-+', max=1) + Product) * STAR
Value = Number | Identifier | Group('(' + Expression + ')')
Infix = Group(Value + (InfixOperator + Value) * STAR)
PyExpression = QuotedString("`", escChar="\\", unquoteResults=True)
Expression <<= Sum | PyExpression
Expression <<= Infix | PyExpression
PyCode = QuotedString("```", escChar="\\", unquoteResults=True
).setResultsName("pycode")