20 lines
485 B
C#
20 lines
485 B
C#
|
using Antlr4.Runtime;
|
||
|
using meowlang.parser.antlr;
|
||
|
|
||
|
namespace meowlang.parser;
|
||
|
|
||
|
public class Parser
|
||
|
{
|
||
|
public static Model? Parse(string path)
|
||
|
{
|
||
|
var lexer = new MeowLexer(new AntlrFileStream(path));
|
||
|
var parser = new MeowParser(new CommonTokenStream(lexer));
|
||
|
var visitor = new Visitor();
|
||
|
var file = parser.file();
|
||
|
if (parser.NumberOfSyntaxErrors > 0)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
return visitor.Visit(file);
|
||
|
}
|
||
|
}
|