disable errors... for now!
This commit is contained in:
parent
579d755205
commit
d003d65a15
|
|
@ -1,9 +1,10 @@
|
|||
import { CompilerError } from '#compiler/compilerError.ts'
|
||||
import { parse } from '#parser/parser2'
|
||||
import { SyntaxNode, Tree } from '#parser/node'
|
||||
import { parser } from '#parser/shrimp.ts'
|
||||
import * as terms from '#parser/shrimp.terms'
|
||||
import { setGlobals } from '#parser/tokenizer'
|
||||
import { tokenizeCurlyString } from '#parser/curlyTokenizer'
|
||||
import type { SyntaxNode, Tree } from '@lezer/common'
|
||||
import { assert, errorMessage } from '#utils/utils'
|
||||
import { toBytecode, type Bytecode, type ProgramItem, bytecodeToString } from 'reefvm'
|
||||
import {
|
||||
|
|
@ -63,13 +64,14 @@ export class Compiler {
|
|||
constructor(public input: string, globals?: string[] | Record<string, any>) {
|
||||
try {
|
||||
if (globals) setGlobals(Array.isArray(globals) ? globals : Object.keys(globals))
|
||||
const cst = parser.parse(input)
|
||||
const errors = checkTreeForErrors(cst)
|
||||
const ast = parse(input)
|
||||
const cst = new Tree(ast)
|
||||
// const errors = checkTreeForErrors(cst)
|
||||
|
||||
const firstError = errors[0]
|
||||
if (firstError) {
|
||||
throw firstError
|
||||
}
|
||||
// const firstError = errors[0]
|
||||
// if (firstError) {
|
||||
// throw firstError
|
||||
// }
|
||||
|
||||
this.#compileCst(cst, input)
|
||||
this.bytecode = toBytecode(this.instructions)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import { CompilerError } from '#compiler/compilerError.ts'
|
||||
import * as terms from '#parser/shrimp.terms'
|
||||
import type { SyntaxNode, Tree } from '@lezer/common'
|
||||
import type { SyntaxNode, Tree } from '#parser/node'
|
||||
|
||||
export const checkTreeForErrors = (tree: Tree): CompilerError[] => {
|
||||
const errors: CompilerError[] = []
|
||||
tree.iterate({
|
||||
enter: (node) => {
|
||||
if (node.type.isError) {
|
||||
errors.push(new CompilerError(`Unexpected syntax.`, node.from, node.to))
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// tree.iterate({
|
||||
// enter: (node) => {
|
||||
// if (node.type.isError) {
|
||||
// errors.push(new CompilerError(`Unexpected syntax.`, node.from, node.to))
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
|
||||
return errors
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user