@ton-community/tlb-parser
Version:
Parse TLB syntax into TypeScript objects
21 lines (17 loc) • 516 B
text/typescript
import type { Node } from 'ohm-js'
import * as ast from '../ast/nodes'
export function withLocations<T extends ast.ASTRootBase>(
astNode: T,
intermediateNode: Node,
): T {
// It exists, but is not listed in TS definitions.
// @ts-ignore
const lineAndColumn = intermediateNode.source.getLineAndColumn()
// This is the only place where we set it, ignore the type error
// @ts-ignore
astNode.locations = {
'line': lineAndColumn.lineNum,
'column': lineAndColumn.colNum,
}
return astNode
}