add debug mode

This commit is contained in:
Alex Zenla
2025-07-26 00:47:32 -07:00
parent 8d8866c26c
commit ff2aaabd93
12 changed files with 109 additions and 19 deletions

View File

@ -5,6 +5,7 @@ import gay.pizza.pork.ast.gen.Node
import gay.pizza.pork.ast.gen.NodeType
import gay.pizza.pork.parser.ParseError
import gay.pizza.pork.parser.ParserNodeAttribution
import gay.pizza.pork.tokenizer.ExpectedTokenError
class PsiBuilderMarkAttribution(val builder: PsiBuilder) : ParserNodeAttribution() {
override fun <T : Node> produce(type: NodeType, block: () -> T): T {
@ -19,6 +20,12 @@ class PsiBuilderMarkAttribution(val builder: PsiBuilder) : ParserNodeAttribution
builder.advanceLexer()
}
throw PorkParser.ExitParser()
} catch (e: ExpectedTokenError) {
marker.error("${e.message}")
while (!builder.eof()) {
builder.advanceLexer()
}
throw PorkParser.ExitParser()
} catch (e: ParseError) {
marker.error(e.error)
while (!builder.eof()) {

View File

@ -177,7 +177,8 @@ object PorkReferenceResolution {
for (file in getRelevantFiles(containingFile)) {
val definitions = PsiTreeUtil.collectElements(file.file) { element ->
element is FunctionDefinitionElement ||
element is LetDefinitionElement
element is LetDefinitionElement ||
element is TypeDefinitionElement
}.filterIsInstance<PorkNamedElement>()
if (name != null) {
val fileFoundDefinition = definitions.firstOrNull {