ti-el
Version:
A TL (Type Language) parser
60 lines (49 loc) • 962 B
TypeScript
import { TLProgram } from './ast'
export type Location = {
line: number,
column: number,
offset: number
}
export type LocationRange = {
start: Location,
end: Location
}
export class SyntaxError {
line: number
column: number
offset: number
location: LocationRange
expected: any[]
found: any
name: string
message: string
}
export type ParserOptions = {
startRule?: string,
tracer?: any,
[key: string]: any
}
export function parse(str: string, options?: ParserOptions): TLProgram
export type Parameter = {
name: string,
type: string,
vector: number,
description: string
}
export type BaseClass = {
name: string,
description: string
}
export type TdClass = {
line: number,
name: string,
kind: 'function' | 'constructor',
description: string,
parameters: Parameter[],
result: string
}
export type TldocOutput = {
baseClasses: BaseClass[],
classes: TdClass[]
}
export function tldoc(input: string): TldocOutput