chharvey / counterpoint

A robust programming language.
GNU Affero General Public License v3.0
2 stars 0 forks source link

Parse Expressions with Integers, Strings, and Identifiers #12

Closed chharvey closed 4 years ago

chharvey commented 4 years ago

Expand the LR syntactic grammar to parse expressions containing integer literals, string literals, string templates, and variable identifiers. Support the same operations as for integers.

ExpressionUnit ::=
    PrimitiveLiteral |
    StringTemplate |
    IDENTIFIER |
    "(" Expression ")"

StringTemplate ::=
    STRING_TEMPLATE_FULL |
    STRING_TEMPLATE_HEAD Expression? (STRING_TEMPLATE_MIDDLE Expression?)* STRING_TEMPLATE_TAIL

PrimitiveLiteral ::=
    NUMBER |
    STRING_LITERAL