tagua-vm / parser

Safe, fast and memory efficient PHP parser (lexical and syntactic analysers, and the Abstract Syntax Tree)
http://tagua.io/
119 stars 15 forks source link

Introduce ternary operator #124

Closed Hywan closed 7 years ago

Hywan commented 7 years ago

Address https://github.com/tagua-vm/parser/issues/14.

Only conditional is introduced now (I don't think there is more though).

New AST nodes: NAryOperation::Ternary and TernaryOperator.

In the case of conditional, the pattern is x op_1 y op_2 z where y is optional. In case it is absent, then we automatically fallback to a binary operation instead of a ternary operation. It is why we have BinaryOperator::Conditional and TernaryOperator::Conditional.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 95.705% when pulling 96df199a4177b8e17f0fa84bab3df61017f2c442 on Hywan:assignment into 872eb5837cb800eede185b7307bda1efb532e3b0 on tagua-vm:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 95.705% when pulling 96df199a4177b8e17f0fa84bab3df61017f2c442 on Hywan:assignment into 872eb5837cb800eede185b7307bda1efb532e3b0 on tagua-vm:master.