GlispGlisp
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
  • API

    • glisp
    • build
    • check
    • eval
    • expand
    • expectedType
    • infer
    • lex
    • parse
    • print
    • session
    • types

glisp


glisp / lex

lex

Classes

LexError

Defined in: lex.ts:492

Thrown by lex on an unrecoverable input (an unexpected character, a bad string escape, an unterminated string, etc.). Carries the full source text and the byte offset where lexing gave up so a host can render a positional error message.

Extends

  • Error

Constructors

Constructor

new LexError(message, source, position): LexError

Defined in: lex.ts:493

Parameters
ParameterType
messagestring
sourcestring
positionnumber
Returns

LexError

Overrides

Error.constructor

Properties

PropertyModifierType
positionreadonlynumber
sourcereadonlystring

Interfaces

Token

Defined in: lex.ts:60

A single lexed token: its kind, the verbatim source slice (text), the half-open source offsets ([start, end)), and a decoded value for kinds that carry one (numbers, strings, booleans, unit, paths).

Properties

PropertyModifierType
endreadonlynumber
kindreadonlyTokenKind
startreadonlynumber
textreadonlystring
value?readonlystring | number | boolean | typeof UNIT | readonly (string | number)[]

Type Aliases

TokenKind

TokenKind = "(" | ")" | "[" | "]" | "{" | "}" | ":" | "=" | "=>" | "^" | "?" | "`" | "~" | "..." | "...~" | "." | "()" | "_" | "!" | "number" | "string" | "boolean" | "identifier" | "pathSegments" | "eof"

Defined in: lex.ts:27

Every kind of token the lexer emits. Punctuation kinds equal their source form (e.g. '(', ':', '=>'); the rest are descriptive names for variable-shape tokens ('number', 'identifier', …). The trailing 'eof' token is always present so consumers can peek past the end without bounds-checking.

Functions

lex()

lex(src): Token[]

Defined in: lex.ts:78

Tokenize Glisp source into a flat token sequence. Whitespace and ;-style comments are skipped. The returned array always ends with an { kind: 'eof' } token. Throws LexError on the first unrecoverable character (bad escape, unterminated string, etc.).

Parameters

ParameterType
srcstring

Returns

Token[]

Edit this page
Prev
infer
Next
parse