class Ven::Reader
- Ven::Reader
- Reference
- Object
Overview
A reader based on Pratt's parsing algorithm.
Included Modules
Defined in:
ven/read.crConstant Summary
-
KEYWORDS =
["_", "&_", "nud", "not", "is", "in", "if", "else", "fun", "given", "loop", "next", "queue", "ensure", "expose", "distinct", "box", "and", "or", "return"] of ::String
-
A list of keywords protected by the reader.
Constructors
Instance Method Summary
-
#before(type : String, unit : -> T = ->led) forall T
Expects type after calling unit.
-
#die(message : String)
Given the explanation message, dies of ParseError.
-
#eoi?
Returns whether this token is a valid statement delimiter.
-
#expect(*restrictions : String)
Reads a word if one of the restrictions matches the current word's type.
-
#is_led?(only pick : Parselet::Led.class | Nil = nil)
Returns whether this word is a led.
-
#is_nud?(only pick : Parselet::Nud.class | Nil = nil)
Returns whether this word is a nud.
-
#is_stmt?
Returns whether this word is a statement.
- #keywords : Array(String)
- #keywords=(keywords : Array(String))
-
#led(level = Precedence::ZERO.value) : Quote
Parses a led expression with precedence level.
-
#led?(only pick : Parselet::Led.class | Nil = nil)
Returns an array of leds that are of
.class
only. -
#module(&)
Performs a module-level parse (zero or more statements followed by EOF).
-
#nud?(only pick : Parselet::Nud.class | Nil = nil)
Returns an array of nuds that are of
.class
only. -
#prepare
Initializes this reader so it is capable of reading base Ven.
-
#read(filename : String, source : String, &block : Quote -> _)
Reads the source under the filename.
-
#repeat(stop : String | Nil = nil, sep : String | Nil = nil, unit : -> T = ->led) forall T
Calls unit repeatedly, remembering what each call results in, and returns an Array of the results.
-
#reset(file : String = "<unknown>", src : String = "")
Resets
-
#statement : Quote
Parses a single statament.
- #to_s(io)
- #word : {type: String, lexeme: String, line: UInt32}
-
#word!(restriction : String)
Reads a word if the type of the current word is restriction.
-
#word!
Consumes a fresh word and returns the former word.
- #world : Ven::World
- #world=(world : Ven::World)
Constructor Detail
Instance Method Detail
Reads a word if one of the restrictions matches the current word's type. Dies of parse error otherwise.
Returns whether this word is a led. pick may be provided to check only certain parselet classes.
Returns whether this word is a nud. pick may be provided to check only certain parselet classes.
Parses a led expression with precedence level.
Returns an array of leds that are of .class
only.
If given no only, or only is nil, returns all leds.
Performs a module-level parse (zero or more statements followed by EOF). Each statement is yielded to block.
Returns an array of nuds that are of .class
only.
If given no only, or only is nil, returns all nuds.
Reads the source under the filename.
Calls unit repeatedly, remembering what each call results in, and returns an Array of the results. Expects a sep after each unit. Terminates at stop.
NOTE either stop or sep, and unit may be omitted;
unit defaults to a #led
.