Skip to content

Commit

Permalink
(#72) Parser: add a failing test for lexer hack investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Feb 23, 2022
1 parent 5bdb7c4 commit c38f690
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"$type": "Cesium.Ast.TranslationUnit, Cesium.Ast",
"Declarations": [
{
"$type": "Cesium.Ast.FunctionDefinition, Cesium.Ast",
"Specifiers": [
{
"$type": "Cesium.Ast.SimpleTypeSpecifier, Cesium.Ast",
"TypeName": "int"
}
],
"Declarator": {
"$type": "Cesium.Ast.Declarator, Cesium.Ast",
"Pointer": null,
"DirectDeclarator": {
"$type": "Cesium.Ast.IdentifierListDirectDeclarator, Cesium.Ast",
"Base": {
"$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast",
"Identifier": "main",
"Base": null
},
"Identifiers": null
}
},
"Declarations": null,
"Statement": {
"$type": "Cesium.Ast.CompoundStatement, Cesium.Ast",
"Block": [
{
"$type": "Cesium.Ast.Declaration, Cesium.Ast",
"Specifiers": [
{
"$type": "Cesium.Ast.SimpleTypeSpecifier, Cesium.Ast",
"TypeName": "int"
}
],
"InitDeclarators": [
{
"$type": "Cesium.Ast.InitDeclarator, Cesium.Ast",
"Declarator": {
"$type": "Cesium.Ast.Declarator, Cesium.Ast",
"Pointer": null,
"DirectDeclarator": {
"$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast",
"Identifier": "exitCode",
"Base": null
}
},
"Initializer": {
"$type": "Cesium.Ast.AssignmentInitializer, Cesium.Ast",
"Expression": {
"$type": "Cesium.Ast.FunctionCallExpression, Cesium.Ast",
"Function": {
"$type": "Cesium.Ast.ConstantExpression, Cesium.Ast",
"Constant": {
"Kind": "Identifier",
"Text": "abs"
}
},
"Arguments": [
{
"$type": "Cesium.Ast.NegationExpression, Cesium.Ast",
"Target": {
"$type": "Cesium.Ast.ConstantExpression, Cesium.Ast",
"Constant": {
"Kind": "IntLiteral",
"Text": "42"
}
}
}
]
}
}
}
]
},
{
"$type": "Cesium.Ast.ExpressionStatement, Cesium.Ast",
"Expression": {
"$type": "Cesium.Ast.FunctionCallExpression, Cesium.Ast",
"Function": {
"$type": "Cesium.Ast.ConstantExpression, Cesium.Ast",
"Constant": {
"Kind": "Identifier",
"Text": "exit"
}
},
"Arguments": [
{
"$type": "Cesium.Ast.ConstantExpression, Cesium.Ast",
"Constant": {
"Kind": "Identifier",
"Text": "exitCode"
}
}
]
}
}
]
}
}
]
}
7 changes: 7 additions & 0 deletions Cesium.Parser.Tests/ParserTests/FullParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ int main()
return foo() + 1;
}");

[Fact]
public Task AbsCallTest() => DoTest(@"int main()
{
int exitCode = abs(-42);
exit(exitCode);
}");

[Fact]
public Task CliImport() => DoTest(@"__cli_import(""Foo.Bar::Baz"")
int foo();
Expand Down

0 comments on commit c38f690

Please sign in to comment.