class Crystal::Parser
inherits Crystal::Lexer
¶
Constants¶
AtomicWithMethodCheck = [:IDENT, :CONST, :+, :-, :*, :/, ://, :%, :|, :&, :^, :~, :!, :**, :<<, :<, :<=, :==, :!=, :=~, :!~, :>>, :>, :>=, :<=>, :===, :[], :[]=, :[]?, :"[", :&+, :&-, :&*, :&**]
¶
[:IDENT, :CONST, :+, :-, :*, :/, ://, :%, :|, :&, :^, :~, :!, :**, :<<, :<, :<=, :==, :!=, :=~, :!~, :>>, :>, :>=, :<=>, :===, :[], :[]=, :[]?, :"[", :&+, :&-, :&*, :&**]
ConstOrDoubleColon = [:CONST, :"::"]
¶
[:CONST, :"::"]
DefOrMacroCheck1 = [:IDENT, :CONST, :"`", :<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
¶
[:IDENT, :CONST, :"`", :<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
DefOrMacroCheck2 = [:<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
¶
[:<<, :<, :<=, :==, :===, :!=, :=~, :!~, :>>, :>, :>=, :+, :-, :*, :/, ://, :!, :~, :%, :&, :|, :^, :**, :[], :[]?, :[]=, :<=>, :&+, :&-, :&*, :&**]
IdentOrConst = [:IDENT, :CONST]
¶
[:IDENT, :CONST]
SemicolonOrNewLine = [:";", :NEWLINE]
¶
[:";", :NEWLINE]
Class methods¶
Methods¶
#add_when_exp(when_exps, exp)
¶
(when_exps, exp)
Adds an expression to all when expressions and error on duplicates
#parse_arg(args, extra_assigns, parentheses, found_default_value, found_splat, found_double_splat, allow_restrictions)
¶
(args, extra_assigns, parentheses, found_default_value, found_splat, found_double_splat, allow_restrictions)
#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)
#parse_call_args(stop_on_do_after_space = false, allow_curly = false, control = false)
¶
(stop_on_do_after_space = false, allow_curly = false, control = false)
#parse_call_args_space_consumed(check_plus_and_minus = true, allow_curly = false, control = false, end_token = :")", allow_beginless_range = false)
¶
(check_plus_and_minus = true, allow_curly = false, control = false, end_token = :")", allow_beginless_range = false)
#parse_generic(expression = false)
¶
(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.
#type_start?(*, consume_newlines)
¶
(*, consume_newlines)
Looks ahead next tokens to check whether they indicate type.
#when_exp_constant?(exp)
¶
(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.