struct

ExpressionParser

Inherits SubParser < Struct < Value < Object

ExpressionParser is a subparser that parses an expression. The following properties are used to detect the end of an expression:

  • expression_indent: the indent of the first token in the expression
    • a token with indent not greater than this ends the expression
  • line_indent: the actual indent of the current line
    • this becomes the block_indent of the next if, for, or while block

Constructors

new(parser : Parser, expression_indent : UInt32, stop : StopAt = StopAt::Normal)
Source
new(parser : Parser, stop : StopAt = StopAt::Normal)
Source

Instance methods

compress
Source
expect(expected : Expecting)
Source
expecting
Source
expecting=(expecting : Expecting)
Source
expression_done?

Given the stop conditions of the current sub-parser, return whether or not the next token will force the sub-parser is forced to stop.

Source
expression_indent
Source
function_call(loc : Location, name : String, receiver : Ast::Expr)
Source
function_call(loc : Location, name : String)
Source
handle_dot
Source
handle_type(loc : Location, type : String)
Source
last_term
Source
last_term!
Source
operators
Source
operators=(operators : Array(Operator))
Source
parse
Source
parse_args(args : Ast::Args = Ast::Args.new) : Ast::Args
Source
parse_array_literal(loc : Location)
Source
parse_const_declaration(loc : Location)
Source
parse_control_statement(loc : Location, word : KeyWord)
Source
parse_for_expression(loc : Location)
Source
parse_if_expression(loc : Location)
Source
parse_let_declaration(loc : Location)
Source
parse_list(exprs : Array(Ast::Expr) = [] of Ast::Expr) : Array(Ast::Expr)
Source
parse_paren_group(loc : Location)
Source
parse_var_declaration(loc : Location)
Source
parse_while_expression(loc : Location)
Source
parse_word(loc : Location, word : String)
Source
pop_term!
Source
push_operator(right_op : Operator)
Source
read_operand
Source
read_operator

Reads the next operator and pushes it onto the stack, then moves on to the operand Peek the next token, and if it ends the expression, leave it there and return

Source
stop
Source
stop=(stop : StopAt)
Source
terms
Source
terms=(terms : Array(Ast::Expr))
Source