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