Skip to content

Latest commit

 

History

History
150 lines (88 loc) · 2.74 KB

File metadata and controls

150 lines (88 loc) · 2.74 KB

lexureParser

Class: Parser

Parses a list of tokens to separate out flags and options.

Hierarchy

  • Parser

Implements

Index

Constructors

Accessors

Methods

Constructors

constructor

Parameters:

Name Type Description
input? Token[] The input tokens.

Returns: Parser

Accessors

finished

  • get finished(): boolean

Whether the parser is finished.

Returns: boolean

Methods

setInput

  • setInput(input: Token[]): this

Sets the input to use. This will reset the parser.

Parameters:

Name Type Description
input Token[] Input to use.

Returns: this

The parser.


setUnorderedStrategy

Sets the strategy for parsing unordered arguments. This can be done in the middle of parsing.

const parser = new Parser(tokens)
  .setUnorderedStrategy(longStrategy())
  .parse();

Parameters:

Name Type
s UnorderedStrategy

Returns: this

The parser.


reset

  • reset(): this

Resets the state of the parser.

Returns: this

The parser.


next

Gets the next parsed tokens. If a parser output is passed in, that output will be mutated, otherwise a new one is made.

Parameters:

Name Type Description
output? ParserOutput Parser output to mutate.

Returns: IteratorResult<ParserOutput>

An iterator result containing parser output.


parse

Runs the parser.

const lexer = new Lexer(input);
const tokens = lexer.lex();
const parser = new Parser(tokens);
const output = parser.parse();

Returns: ParserOutput

The parser output.