Sheety::Tokens::Operator
Inherits Sheety::Token < Reference < Object
Operator token with precedence handling (shunting-yard algorithm)
Constants
N_ARGS = {"u-" => 1, "u+" => 1, "%" => 1}
Number of arguments for each operator
PRECEDENCES = {":" => 8, " " => 8, "," => 8, "u-" => 7, "u+" => 7, "%" => 6, "^" => 5, "*" => 4, "/" => 4, "+" => 3, "-" => 3, "&" => 2, "=" => 1, "<" => 1, ">" => 1, "<=" => 1, ">=" => 1, "<>" => 1}
Operator precedence levels (higher = higher precedence)
Constructors
new(source : String, context : Hash(String, BigFloat | String) | Nil = nil)
SourceInstance methods
ast(tokens : Array(Token), stack : Array(Token), builder : AstBuilder) : Nil
Add this token to the AST - called during parsing
n_args
Sourceoperator_name
Sourceoperator_name=(operator_name : String)
Sourcepred
Sourceto_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>
update_input_tokens(*input_tokens : Token) : Nil
Update input tokens (used by operators and functions)