class

Syntax::Parser

Inherits Syntax::Lexer < Reference < Object

Constants

AtomicWithMethodCheck = [:IDENT, :CONST, :+, :-, :*, :/, ://, :%, :|, :&, :^, :~, :!, :**, :<<, :<, :<=, :==, :!=, :=~, :!~, :>>, :>, :>=, :<=>, :===, :[], :[]=, :[]?, :"[", :&+, :&-, :&*, :&**]
ConstOrDoubleColon = [:CONST, :"::"]
DefOrMacroCheck1 = [:IDENT, :CONST, :"`", :<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
DefOrMacroCheck2 = [:<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
IdentOrConst = [:IDENT, :CONST]
SemicolonOrNewLine = [:";", :NEWLINE]

Constructors

new(str, string_pool : StringPool | Nil = nil, var_scopes : Array(Set(String)) = [Set(String).new])
Source

Class methods

parse(str, string_pool : StringPool | Nil = nil, var_scopes = [Set(String).new]) : ASTNode
Source

Instance methods

add_when_exp(when_exps, exp)

Adds an expression to all when expressions and error on duplicates

Source
call_block_arg_follows?
Source
can_be_assigned?(node)
Source
check(token_types : Array)
Source
check(token_type)
Source
check_const
Source
check_ident(value)
Source
check_ident
Source
check_macro_expression_end
Source
check_macro_skip_whitespace
Source
check_not_inside_def(message, &)
Source
check_not_pipe_before_proc_literal_body
Source
check_token(value)
Source
check_type_declaration
Source
check_valid_def_name
Source
check_valid_def_op_name
Source
check_valid_exhaustive_expression(exp)
Source
check_void_expression_keyword
Source
check_void_value(exp, location)
Source
compute_block_arg_yields(block_arg)
Source
consume_def_equals_sign_skip_space
Source
consume_def_or_macro_name
Source
consume_delimiter(pieces, delimiter_state, has_interpolation)
Source
consume_heredoc(delimiter_state, node)
Source
consume_heredocs
Source
consume_regex_options
Source
def_nest
Source
def_nest=(def_nest : Int32)
Source
delimiter_or_type_suffix?
Source
end_token?
Source
fun_nest
Source
fun_nest=(fun_nest : Int32)
Source
inside_def?
Source
inside_fun?
Source
invalid_internal_name?(keyword)
Source
make_named_tuple_type(named_args)
Source
make_nilable_expression(type)
Source
make_nilable_type(type)
Source
make_pointer_type(type)
Source
make_static_array_type(type, size)
Source
make_tuple_type(types)
Source
multi_assign_middle?(exp)
Source
multi_assign_target?(exp)
Source
multiassign_left_hand(exp)
Source
named_tuple_start?
Source
needs_heredoc_indent_removed?(delimiter_state)
Source
new_hash_literal(entries, line, column, end_location, allow_of = true)
Source
new_node_check_type_declaration(klass)
Source
new_node_check_type_declaration(klass, &)
Source
new_range(exp, location, exclusive)
Source
next_comes_colon_space?
Source
next_comes_plus_or_minus?
Source
next_token
Source
node_and_next_token(node)
Source
open(symbol, location = @token.location, &)
Source
parse(mode : ParseMode)
Source
parse
Source
parse_add_or_sub
Source
parse_alias
Source
parse_and
Source
parse_annotation
Source
parse_annotation_def
Source
parse_arg(args, extra_assigns, parentheses, found_default_value, found_splat, found_double_splat, allow_restrictions)
Source
parse_arg_name(location, extra_assigns, allow_external_name)
Source
parse_array_literal
Source
parse_as(atomic, klass = Cast)
Source
parse_as?(atomic)
Source
parse_asm
Source
parse_asm_clobbers
Source
parse_asm_operand
Source
parse_asm_operands
Source
parse_asm_options
Source
parse_atomic
Source
parse_atomic_method_suffix(atomic, location)
Source
parse_atomic_method_suffix_special(call, location)
Source
parse_atomic_type
Source
parse_atomic_type_with_suffix
Source
parse_atomic_with_method
Source
parse_atomic_without_location
Source
parse_bare_proc_type

Parse a bare proc type like A, B, C -> D. Generally it is entry point of type parsing and it is used on the context expected type (e.g. type restrictions, rhs of alias and more)

Source
parse_begin
Source
parse_block(block, stop_on_do = false)
Source
parse_block2
Source
parse_block_arg(extra_assigns)
Source
parse_break
Source
parse_c_struct_or_union(union : Bool)
Source
parse_c_struct_or_union_body
Source
parse_c_struct_or_union_fields(exps)
Source
parse_call_arg(found_double_splat = false)
Source
parse_call_args(stop_on_do_after_space = false, allow_curly = false, control = false)
Source
parse_call_args_named_args(location, args, first_name, allow_newline)
Source
parse_call_args_space_consumed(check_plus_and_minus = true, allow_curly = false, control = false, end_token = :")", allow_beginless_range = false)
Source
parse_call_block_arg(args, check_paren, named_args = nil)
Source
parse_call_block_arg_after_dot(obj)
Source
parse_case
Source
parse_class_def(is_abstract = false, is_struct = false, doc = nil)
Source
parse_cmp
Source
parse_control_expression(klass)
Source
parse_curly_block(block)
Source
parse_custom_literal(type)
Source
parse_def(is_abstract = false, is_macro_def = false, doc = nil)
Source
parse_def_free_vars
Source
parse_def_helper(is_abstract = false)
Source
parse_delimiter(want_skip_space = true)
Source
parse_empty_array_literal
Source
parse_enum_body
Source
parse_enum_def
Source
parse_equality
Source
parse_exception_handler(exp, implicit = false, begin_location = nil)
Source
parse_expression
Source
parse_expression_inside_macro
Source
parse_expression_suffix(atomic, location)
Source
parse_expression_suffix(location, &)
Source
parse_expressions
Source
parse_expressions_internal
Source
parse_extend
Source
parse_fun_def(top_level, require_body = false)
Source
parse_fun_literal
Source
parse_fun_literal_arg
Source
parse_fun_pointer
Source
parse_generic(global, location, expression)
Source
parse_generic(expression = false)

Parse generic type path like A::B(C, D)?. This method is used to parse not only a type, but also an expression represents type. And it also consumes prefix :: to specify global path.

Source
parse_generic_or_custom_literal
Source
parse_generic_or_global_call
Source
parse_hash_literal(first_key, location, allow_of)
Source
parse_hash_or_tuple_literal(allow_of = true)
Source
parse_if(check_end = true)
Source
parse_if_after_condition(cond, location, check_end)
Source
parse_include
Source
parse_include_or_extend(klass)
Source
parse_instance_sizeof
Source
parse_is_a(atomic)
Source
parse_lib
Source
parse_lib_body
Source
parse_lib_body_exp
Source
parse_lib_body_exp_without_location
Source
parse_logical_and
Source
parse_logical_or
Source
parse_macro
Source
parse_macro_body(start_location, macro_state = Token::MacroState.default)
Source
parse_macro_control(start_location, macro_state = Token::MacroState.default)
Source
parse_macro_expression
Source
parse_macro_if(start_location, macro_state, check_end = true, is_unless = false)
Source
parse_macro_var_exps
Source
parse_module_def
Source
parse_mul_or_div
Source
parse_multi_assign
Source
parse_named_args(location, first_name = nil, allow_newline = false)
Source
parse_named_tuple(location, first_key)
Source
parse_named_tuple(location)
Source
parse_named_type_args(end_token)
Source
parse_negation_suffix(atomic)
Source
parse_next
Source
parse_nil?(atomic)
Source
parse_offsetof
Source
parse_op_assign(allow_ops = true, allow_suffix = true)
Source
parse_op_assign_no_control(allow_ops = true, allow_suffix = true)
Source
parse_or
Source
parse_out
Source
parse_parenthesized_expression
Source
parse_path(global, location)
Source
parse_path

Parse type path. It also consumes prefix :: to specify global path.

Source
parse_percent_macro_control
Source
parse_percent_macro_expression
Source
parse_pointerof
Source
parse_pow
Source
parse_prefix
Source
parse_proc_type_output(input_types, location)
Source
parse_question_colon
Source
parse_range
Source
parse_require
Source
parse_rescue
Source
parse_rescue_types
Source
parse_responds_to(atomic)
Source
parse_responds_to_name
Source
parse_return
Source
parse_select
Source
parse_shift
Source
parse_single_arg
Source
parse_sizeof(klass)
Source
parse_sizeof
Source
parse_string_array
Source
parse_string_or_symbol_array(klass, elements_type)
Source
parse_string_without_interpolation(context, want_skip_space = true)
Source
parse_symbol_array
Source
parse_to_def(a_def)
Source
parse_tuple(first_exp, location)
Source
parse_type_arg
Source
parse_type_args(name)
Source
parse_type_declaration(var)
Source
parse_type_def
Source
parse_type_splat
Source
parse_type_suffix(type)
Source
parse_type_vars
Source
parse_typeof
Source
parse_union_type
Source
parse_union_types(end_token, *, allow_splats = false)
Source
parse_unless
Source
parse_unless_after_condition(cond, location)
Source
parse_until
Source
parse_var_or_call(global = false, force_call = false)
Source
parse_visibility_modifier(modifier)
Source
parse_when_expression(cond, single, exhaustive)
Source
parse_while
Source
parse_while_or_until(klass)
Source
parse_yield(scope = nil, location = @token.location)
Source
parse_yield_with_scope
Source
prepare_parse_def
Source
preserve_stop_on_do(new_value : Bool = false, &)
Source
push_var(var : Var | Arg)
Source
push_var(var : TypeDeclaration)
Source
push_var(node)
Source
push_var_name(name)
Source
push_vars(vars)
Source
push_visibility
Source
remove_heredoc_from_line(line, indent, line_number)
Source
remove_heredoc_indent(pieces : Array, indent)
Source
set_visibility(node)
Source
string_literal_start?
Source
temp_arg_name
Source
type_nest
Source
type_nest=(type_nest : Int32)
Source
type_path_start?
Source
type_start?
Source
type_start?(*, consume_newlines)

Looks ahead next tokens to check whether they indicate type.

Source
unexpected_token(msg : String | Nil = nil, token : Token = @token)
Source
unexpected_token_in_atomic
Source
valid_select_when?(node)
Source
var?(name)
Source
var_in_scope?(name)
Source
visibility
Source
visibility=(visibility : Visibility | Nil)
Source
wants_doc=(wants_doc)
Source
wants_doc?
Source
when_exp_constant?(exp)

Only error on constant values, because calls might have side-effects: a first call might return one value and not match the case value, but the second same call returns something different and matches it.

Source
when_expression_end
Source
with_isolated_var_scope(create_scope = true, &)

If create_scope is true, creates an isolated variable scope and returns the yield result, resetting the scope afterwards. Otherwise simply returns the yield result without touching the scopes.

Source
with_lexical_var_scope

Creates a new variable scope with the same variables as the current scope, and then returns the yield result, resetting the scope afterwards.

Source

Macros

parse_operator(name, next_operator, node, operators, right_associative = false)
Source

Nested types