feat: 语法分析的详细错误信息 (#63)

Reviewed-on: PostGuard/Canon#63
This commit is contained in:
2024-04-28 15:13:09 +08:00
parent 73dba8b1db
commit d84b254716
4 changed files with 219 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
using Canon.Core.Enums;
using Canon.Core.Exceptions;
using Canon.Core.GrammarParser;
using Canon.Core.LexicalParser;
using Canon.Core.SyntaxNodes;
@@ -69,11 +70,11 @@ public interface IGrammarParser
}
else
{
throw new InvalidOperationException("Run out of token but not accept");
throw new GrammarException(stack.Peek().State);
}
}
throw new InvalidOperationException("Failed to analyse input grammar");
throw new GrammarException(stack.Peek().State, enumerator.Current);
}
}