jackfiled
4b6635796c
Co-authored-by: Huaps <1183155719@qq.com> Co-authored-by: duqoo <92306417+duqoo@users.noreply.github.com> Reviewed-on: PostGuard/Canon#38
34 lines
946 B
C#
34 lines
946 B
C#
using Canon.Core.Abstractions;
|
|
using Canon.Core.CodeGenerators;
|
|
using Canon.Core.LexicalParser;
|
|
using Canon.Core.SyntaxNodes;
|
|
using Canon.Tests.GeneratedParserTests;
|
|
using Canon.Tests.Utils;
|
|
|
|
namespace Canon.Tests.CCodeGeneratorTests;
|
|
|
|
public class BasicTests
|
|
{
|
|
private readonly IGrammarParser _parser = GeneratedGrammarParser.Instance;
|
|
private readonly ILexer _lexer = new Lexer();
|
|
|
|
[Fact]
|
|
public void ProgramStructTest()
|
|
{
|
|
CCodeBuilder builder = new();
|
|
|
|
const string program = """
|
|
program DoNothing;
|
|
begin
|
|
end.
|
|
""";
|
|
|
|
IEnumerable<SemanticToken> tokens = _lexer.Tokenize(new StringSourceReader(program));
|
|
|
|
ProgramStruct root = _parser.Analyse(tokens);
|
|
root.GenerateCCode(builder);
|
|
|
|
Assert.Equal("#include <PascalCoreLib.h>", builder.Build());
|
|
}
|
|
}
|