class Myst::Parser
- Myst::Parser
- Myst::Lexer
- Reference
- Object
Defined in:
myst/syntax/parser.crConstructors
Class Method Summary
Instance Method Summary
- #accept(*types : Token::Type)
- #accept_delimiter
- #expect(*types : Token::Type)
- #expect_delimiter
- #expect_delimiter_or_eof
- #is_local_var?(name : String)
-
#modified_ident?(ident : String)
Returns true if the given identifier is modified (i.e., ends with a
?
or!
). -
#parse
Parse the entirety of the given source.
-
#parse_additive(left = nil)
Arithmetic is left-associative.
- #parse_anonymous_function
- #parse_assign
-
#parse_code_block(*terminators)
A code block is a set of expressions contained by some other expression.
- #parse_comparative
- #parse_conditional
- #parse_def
- #parse_def_name
- #parse_doc_comment
- #parse_equality
- #parse_exception_handler
- #parse_expression
- #parse_extend
- #parse_flow_control
- #parse_function_capture
- #parse_include
- #parse_instantiation
- #parse_list_literal
- #parse_literal
- #parse_logical_and
- #parse_logical_or
- #parse_loop
- #parse_magic_constant
- #parse_map_key
- #parse_map_literal
- #parse_match
- #parse_module_def
- #parse_multiplicative(left = nil)
- #parse_optional_block
- #parse_optional_type_restriction(pipe_is_ambiguous = false)
- #parse_param(allow_splat = true, is_block = false)
-
#parse_param_list(into target : Def, require_parens = false)
If a Def has parameters, they must be parenthesized.
- #parse_postfix(receiver = nil)
- #parse_primary
- #parse_require
-
#parse_single_type_path
This should use
#parse_type_path
to avoid nested looping in this method. - #parse_string_literal
- #parse_type_def
- #parse_type_path
- #parse_unary
- #parse_value_interpolation
- #parse_var_or_call(receiver = nil)
- #pop_var_scope
- #push_local_var(name : String)
- #push_var_scope(scope = Set(String).new)
-
#skip_space
Skip through whitespace tokens, but only if the current token is already a whitespace token.
- #skip_space_and_newlines
Instance methods inherited from class Myst::Lexer
advance_token
advance_token,
brace_stack : Array(Char)
brace_stack,
brace_stack=(brace_stack : Array(Char))
brace_stack=,
check_for_keyword
check_for_keyword,
col : Int32
col,
col=(col : Int32)
col=,
consume_comment
consume_comment,
consume_constant
consume_constant,
consume_identifier
consume_identifier,
consume_numeric
consume_numeric,
consume_symbol_or_colon
consume_symbol_or_colon,
consume_whitespace
consume_whitespace,
context_stack : Array(Context)
context_stack,
context_stack=(context_stack : Array(Context))
context_stack=,
current_brace : Char
current_brace,
current_char : Char
current_char,
current_context
current_context,
current_location
current_location,
current_token : Token
current_token,
current_token=(current_token : Token)
current_token=,
finalize_token
finalize_token,
finished? : Bool
finished?,
last_char : Char
last_char,
last_char=(last_char : Char)
last_char=,
lex_all
lex_all,
peek_char : Char
peek_char,
pop_brace(type : Symbol)
pop_brace,
pop_context
pop_context,
push_brace(type : Symbol)
push_brace,
push_context(context : Context)
push_context,
read_char(save_to_buffer = true) : Char
read_char,
read_normal_token
read_normal_token,
read_string_interp_token
read_string_interp_token,
read_string_token
read_string_token,
read_token
read_token,
reader : Reader
reader,
reader=(reader : Reader)
reader=,
replace_escape_characters(raw)
replace_escape_characters,
row : Int32
row,
row=(row : Int32)
row=,
skip_char : Char
skip_char,
source_file : String
source_file,
source_file=(source_file : String)
source_file=,
token_is_empty?
token_is_empty?,
tokens : Array(Token)
tokens,
tokens=(tokens : Array(Token))
tokens=
Constructor methods inherited from class Myst::Lexer
new(source : IO, source_file : String, row_start : Int32 = 1, col_start : Int32 = 0)
new
Constructor Detail
Class Method Detail
Instance Method Detail
Returns true if the given identifier is modified (i.e., ends with a
?
or !
).
Parse the entirety of the given source. Currently, this assumes valid input and will only end when an EOF is encountered.
Arithmetic is left-associative. 1 - 1 - 1
must be parsed as
((1 - 1) - 1)
to follow mathematic precedence and give the right result
of -2
, rather than (1 - (1 - 1))
, which would yield 0
.
A code block is a set of expressions contained by some other expression. For example, the body of a method definition.
If a Def has parameters, they must be parenthesized. If the token after the opening parenthesis is a closing one, then there are no parameters.
This should use #parse_type_path
to avoid nested looping in this method.
Skip through whitespace tokens, but only if the current token is already a whitespace token.