Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/markProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {CustomFunctions} from './rawParser'
import type {ParseOptions} from './types'

export type MarkName =
Expand All @@ -20,6 +21,7 @@ export type MarkName =
| 'float'
| 'func_args_end'
| 'func_call'
| 'func_decl'
| 'ident'
| 'inc_range'
| 'integer'
Expand Down Expand Up @@ -53,19 +55,28 @@ export interface Mark {
position: number
}

export type FunctionId = `${string}::${string}`

export type MarkVisitor<T> = Record<string, MarkVisitorFunc<T>>
export type MarkVisitorFunc<T> = (p: MarkProcessor, mark: Mark) => T

export class MarkProcessor {
private string: string
private _string: string
private marks: Mark[]
private index: number
customFunctions: CustomFunctions
parseOptions: ParseOptions
allowBoost = false

constructor(string: string, marks: Mark[], parseOptions: ParseOptions) {
this.string = string
constructor(
string: string,
marks: Mark[],
customFunctions: CustomFunctions,
parseOptions: ParseOptions,
) {
this._string = string
this.marks = marks
this.customFunctions = customFunctions
this.index = 0
this.parseOptions = parseOptions
}
Expand Down Expand Up @@ -108,4 +119,8 @@ export class MarkProcessor {
const pos = this.marks[this.index].position
return this.string.slice(pos, pos + len)
}

get string(): string {
return this._string
}
}
8 changes: 8 additions & 0 deletions src/nodeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ export interface ValueNode<P = any> {
value: P
}

export interface FunctionDeclarationNode {
type: 'FuncDeclaration'
namespace: string
name: string
params: ParameterNode[]
body: ExprNode
}

export interface FlatMapNode extends BaseNode {
type: 'FlatMap'
base: ExprNode
Expand Down
Loading