Protean-Labs / mesh

The Mesh Engine that implements the Mesh Language, a computational language for web3.
Apache License 2.0
1 stars 0 forks source link

Prefix operators parsing #5

Closed cvauclair closed 3 years ago

cvauclair commented 3 years ago

Description

The Mesh Engine should be able to parse expressions containing prefix operators. Prefix operators consist of any sequence of the following characters: +, -, *, /, >, <, =, ?, |, $, #, @, ~, !, %.

Examples:

& a
$a
~a
!@!@ b
cvauclair commented 3 years ago

@ThierryBleau should the negation symbol be considered a prefix operator or part of the literal? E.g.: Should -2 be parsed as ELit(Int(-2)) or EApp(EVar("-"), ELit(Int(2)))?

ThierryBleau commented 3 years ago

How does OCaml handle it?

cvauclair commented 3 years ago

I believe it's handled as an operator

ThierryBleau commented 3 years ago

Ok so we can settle for that now and revisit if it would be desirable to also add minuses as part of literals