Skip to main content

Module expressions

Module expressions 

Source
Expand description

Precedence-climbing expression parser.

Expressions are parsed via a hand-written recursive-descent chain that encodes operator precedence through the call stack. From lowest to highest:

parse_expression        (entry point, delegates to equality)
  |- parse_logical      (and or)
     |- parse_equality     (== !=)
         |- parse_comparison  (< <= > >= += -= *= /=)
              |- parse_term   (+ -)
                   |- parse_factor  (* /)
                        |- parse_unary   (! -)
                             |- parse_primary  (literals, identifiers, calls, lambdas, โ€ฆ)
                                  |- parse_postfix  (. method chains)

Every function returns an [Expression] node with its source [Span] set to the full extent of the sub-expression it consumed.

Modulesยง

comparsion ๐Ÿ”’
equality ๐Ÿ”’
factor ๐Ÿ”’
logical ๐Ÿ”’
postfix ๐Ÿ”’
primary ๐Ÿ”’
struct_literal ๐Ÿ”’
Record (struct) literal parser: Name { field: value, ... }.
term ๐Ÿ”’
unary ๐Ÿ”’