syntax.lexer.shell.Lexer
type pub LexerA lexer for common shell syntax, such as Bash and Zsh.
Static methods
new
Show source codeHide source code
fn pub static new(bytes: ref ByteArray) -> Lexer {
Lexer(buffer: Buffer.new(bytes), keywords: Keywords.new(KEYWORDS))
}fn pub static new(bytes: ref ByteArray) -> LexerReturns a new Lexer that lexes the given input.
Instance methods
buffer
Show source codeHide source code
fn pub mut buffer -> mut Buffer {
@buffer
}fn pub mut buffer -> mut BufferThe buffer to turn into a token stream.
next
Show source codeHide source code
fn pub mut next -> Option[Token] {
match @buffer.get {
case bytes.DQUOTE -> Option.Some(helpers.double_string(@buffer))
case bytes.SQUOTE -> Option.Some(helpers.single_string(@buffer))
case bytes.HASH -> Option.Some(helpers.line_comment(@buffer))
case byte if bytes.digit?(byte) -> Option.Some(helpers.integer(@buffer))
case byte if bytes.letter?(byte) -> Option.Some(word)
case byte if bytes.whitespace?(byte) -> {
Option.Some(helpers.whitespace(@buffer))
}
case byte if bytes.multibyte?(byte) -> {
Option.Some(helpers.multi_byte(@buffer))
}
case EOF -> Option.None
case _ -> Option.Some(helpers.single_byte(@buffer))
}
}fn pub mut next -> Option[Token]Returns the next token in the token stream.
to_array
Show source codeHide source code
fn pub move to_array -> Array[Token] {
let tokens = []
loop {
let Some(t) = self.next else break
tokens.push(t)
}
tokens
}fn pub move to_array -> Array[Token]Returns an Array containing all the tokens in the token stream.
Implemented traits
Lexer
impl Lexer for Lexer