class TopDown::Parser::ParseletLiteral
- TopDown::Parser::ParseletLiteral
- Reference
- Object
Overview
This type is used for documentation purpose only. It represents an element to parse inside macro.
Could be one of the following:
- a
CharLiteral
, to parse exactly oneChar
- a
StringLiteral
, to parse an exactString
- a
RegexLiteral
, to parse the given pattern, returns the matchedString
. ($~, $0, $1, ... could be used after) - a
RangeLiteral(Char, Char)
, to parse anyChar
between the range - a
SymbolLiteral
, to parse an entire syntax, returns the result of the syntax, seeParser.syntax
- an one-value
ArrayLiteral
, to parse a token, returns the value of matched token - a
Call
:|
: to parse a union, seeParser.union
.any
, to parse anyChar
except EOF.[any]
, to parse any token except EOF.not(parselet)
, to parse any char, except if parselet matches.
parse('💎')
parse("foo")
parse(/\d+/, &.to_i)
parse(/"(([^"\\]|\\.)*)"/) { $1 }
parse(:expression)
parse(["+="])
parse("foo" | :value | '💎')
# equivalent to:
union do
parse("foo")
parse(:value)
parse('💎')
end
parse(any) # any char except '\0'
parse([any]) # any token except EOF
parse(not('\n')) # any char except '\n' & EOF
parse(not(["+"])) # any token except "+" & EOF
parse(not("foo")) # any char or fail on "foo".
See Parser.parse
.