Interface TwingTokenStream
interface TwingTokenStream { current: Token; source: TwingSource; expect(type: TokenType,
value?: | null | string | number | string[],
message?: null | string): Token; injectTokens(tokens: Token[]): void; isEOF(): boolean; look(number: number): Token; next(): Token; nextIf(primary: TokenType,
secondary?: string | string[]): Token; test(type: TokenType,
value?: string | number | string[]): boolean; toAst(): Token[]; } Properties
Readonly
current
current: Token
Methods
expect
- expect(type, value?, message?): Token
Parameters
- type: TokenType
Optional
value:
| null
| string
| number
| string[]Optional
message: null | string
Returns Token
injectTokens
- injectTokens(tokens): void
Returns void
isEOF
- isEOF(): boolean
Returns boolean
boolean
look
- look(number): Token
Returns Token
next
- next(): Token
Returns Token
nextIf
- nextIf(primary, secondary?): Token
Parameters
- primary: TokenType
Optional
secondary: string | string[]
Returns Token
test
- test(type, value?): boolean
Parameters
- type: TokenType
Optional
value: string | number | string[]
Returns boolean
toAst
- toAst(): Token[]
Returns Token[]
Tests a token and returns it or throws a syntax error.