summaryrefslogtreecommitdiff
path: root/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'Compiler')
-rw-r--r--Compiler/CCompilerVisitor.cs419
-rw-r--r--Compiler/CGrammar.g459
-rw-r--r--Compiler/CommentCompilationMode.cs10
-rw-r--r--Compiler/Compiler.csproj2
-rw-r--r--Compiler/CompilerExtensions.cs12
-rw-r--r--Compiler/CompilerOptions.cs (renamed from Compiler/Options.cs)5
-rw-r--r--Compiler/Program.cs17
-rw-r--r--Compiler/gen/CGrammar.interp51
-rw-r--r--Compiler/gen/CGrammar.tokens82
-rw-r--r--Compiler/gen/CGrammarBaseVisitor.cs338
-rw-r--r--Compiler/gen/CGrammarLexer.cs138
-rw-r--r--Compiler/gen/CGrammarLexer.interp68
-rw-r--r--Compiler/gen/CGrammarLexer.tokens82
-rw-r--r--Compiler/gen/CGrammarParser.cs1506
-rw-r--r--Compiler/gen/CGrammarVisitor.cs230
15 files changed, 2572 insertions, 447 deletions
diff --git a/Compiler/CCompilerVisitor.cs b/Compiler/CCompilerVisitor.cs
index 7bbbeda..aa08147 100644
--- a/Compiler/CCompilerVisitor.cs
+++ b/Compiler/CCompilerVisitor.cs
@@ -1,26 +1,90 @@
namespace Q1.Compiler;
+using Antlr4.Runtime.Tree;
+using Emulator;
+
public class CCompilerVisitor : CGrammarBaseVisitor<string?>
{
- private int _branchCount = 1;
- private List<string> _instructions = new();
- private string GetBranchLabel(string type)
+ private int _branchCount = 1;
+ private List<string> _instructions = new();
+ private Stack<Dictionary<string, int>> _variableStack = new();
+ private int _memPointer = Q1Layout.FreeMemoryStart;
+
+ private const int ColumnWidth = 30;
+
+ public readonly CommentCompilationMode CommentMode;
+
+ public CCompilerVisitor(CommentCompilationMode commentMode)
+ {
+ this.CommentMode = commentMode;
+ }
+
+ private int FindVariable(string varName)
+ {
+ foreach (Dictionary<string, int> variables in this._variableStack)
+ {
+ if (variables.TryGetValue(varName, out int address))
+ return address;
+ }
+
+ throw new CompilerException($"Variable {varName} could not be found in current scope.");
+ }
+
+ private int Alloc(int size)
+ {
+ int loc = this._memPointer;
+ this._memPointer += size;
+
+ return loc;
+ }
+
+ private string GenerateBranchLabel(string type)
{
return $"_{type}_{_branchCount++}";
}
- private void Instruction(string instruction)
+ private void Instruction(string instruction, string? generatedComment = null)
{
this._instructions.Add($" {instruction}");
+ if (generatedComment != null)
+ this.CommentLastInstruction(generatedComment);
}
private void Blank()
{
this._instructions.Add("");
}
- private void Label(string name)
+ private void Label(string name, string? generatedComment = null)
{
this._instructions.Add($"{name}:");
+ if (generatedComment != null)
+ this.CommentLastInstruction(generatedComment);
+ }
+ private void UserComment(string comment)
+ {
+ if (this.CommentMode.HasFlag(CommentCompilationMode.UserDefined))
+ this._instructions.Add($" ; {comment}");
}
+ private void GeneratedComment(string comment)
+ {
+ if (this.CommentMode.HasFlag(CommentCompilationMode.Generated))
+ this._instructions.Add($"{"".PadRight(CCompilerVisitor.ColumnWidth)}; {comment}");
+ }
+
+ private void CommentLastInstruction(string comment)
+ {
+ if (!this.CommentMode.HasFlag(CommentCompilationMode.Generated))
+ return;
+
+ if (this._instructions.Count == 0)
+ throw new Exception("Cannot add comment to last instruction, there are none");
+
+ string lastInstruction = this._instructions[^1];
+ lastInstruction = $"{lastInstruction.PadRight(CCompilerVisitor.ColumnWidth)}; {comment}";
+
+ this._instructions[^1] = lastInstruction;
+ }
+
+
public IEnumerable<string> Compile(CGrammarParser.ProgramContext program)
{
this.Visit(program);
@@ -29,11 +93,17 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
public override string? VisitFunction(CGrammarParser.FunctionContext context)
{
- string functionName = context.ID().GetText();
+ string functionName = context.name.Text;
+ this._variableStack.Push(new());
+
this.Label($"_{functionName}");
this.VisitChildren(context);
+ this.Instruction("mov 0, V0", "fallback return 0");
+ this.Instruction("ret");
this.Blank();
+ this._variableStack.Pop();
+
return null;
}
public override string? VisitParenthesizedExpression(CGrammarParser.ParenthesizedExpressionContext context)
@@ -47,7 +117,7 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
string? expression = this.Visit(context.expression());
if (expression != null)
{
- this.Instruction($"mov {expression}, V0");
+ this.Instruction($"mov {expression}, V0", "return value");
this.Instruction($"ret");
}
else
@@ -93,15 +163,30 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
if (left == null)
throw new CompilerException($"Left operand for {operationFriendlyName} was not an expression.");
- this.Instruction($"push {left}");
+ this.Instruction($"push {left}", "left operand");
string? right = this.Visit(rightExpr);
if (right == null)
throw new CompilerException($"Right operand for {operationFriendlyName} was not an expression.");
- this.Instruction($"mov {right}, V1");
- this.Instruction($"pop V0");
- this.Instruction($"{operation} V0, V1");
+ this.Instruction($"mov {right}, V1", "right operand");
+ this.Instruction($"pop V0", "get left operand back");
+ this.Instruction($"{operation} V0, V1", $"compute {operationFriendlyName}");
+ }
+ private string BaseBinaryCompoundOperation(CGrammarParser.TargetContext leftTarget, CGrammarParser.ExpressionContext rightExpr, string operation, string operationFriendlyName, string operationOutput)
+ {
+ string? left = this.Visit(leftTarget);
+ if (left == null)
+ throw new CompilerException($"Left operand for {operationFriendlyName} was not an expression.");
+
+ string? right = this.Visit(rightExpr);
+ if (right == null)
+ throw new CompilerException($"Right operand for {operationFriendlyName} was not an expression.");
+
+ // No need for stack maniupulation because left is a target and is assumed to stay constant
+ this.Instruction($"{operation} {left}, {right}", $"compute {operationFriendlyName}");
+ this.Instruction($"mov {operationOutput}, {left}", "store back into left param");
+ return left;
}
public override string? VisitAddExpression(CGrammarParser.AddExpressionContext context)
{
@@ -160,23 +245,23 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
if (left == null)
throw new CompilerException("Left operand for logical OR was not an expression.");
- string clauseBranch = this.GetBranchLabel("clause");
- string endBranch = this.GetBranchLabel("end");
+ string clauseBranch = this.GenerateBranchLabel("clause");
+ string endBranch = this.GenerateBranchLabel("end");
- this.Instruction($"cmp {left}, 0");
- this.Instruction("bz"); // implicit LX
+ this.Instruction($"cmp {left}, 0", "logical or");
+ this.Instruction("bz"); // implicit LX
this.Instruction($"jmp {clauseBranch}"); // only if bz is not 0
- this.Instruction("mov 1, V0");
+ this.Instruction("mov 1, V0", "first operand succeeded, store 1 and skip second operand");
this.Instruction($"jmp {endBranch}");
this.Label(clauseBranch);
-
+
string? right = this.Visit(context.right);
if (right == null)
throw new CompilerException("Right operand for logical OR was not an expression.");
-
- this.Instruction($"cmp {right}, 0");
+
+ this.Instruction($"cmp {right}, 0", "compare result from second operand to 0");
this.Instruction("not");
- this.Instruction("mov LX, V0");
+ this.Instruction("mov LX, V0", "store second operand result");
this.Label(endBranch);
return "V0";
@@ -187,24 +272,24 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
if (left == null)
throw new CompilerException("Left operand for logical OR was not an expression.");
- string clauseBranch = this.GetBranchLabel("clause");
- string endBranch = this.GetBranchLabel("end");
-
- this.Instruction($"cmp {left}, 0");
+ string clauseBranch = this.GenerateBranchLabel("clause");
+ string endBranch = this.GenerateBranchLabel("end");
+
+ this.Instruction($"cmp {left}, 0", "logical and");
this.Instruction("not");
this.Instruction("bz"); // implicit LX
this.Instruction($"jmp {clauseBranch}"); // only if bz is not 0
- this.Instruction("mov 0, V0");
+ this.Instruction("mov 0, V0", "first operand failed, store 0 and skip second");
this.Instruction($"jmp {endBranch}");
this.Label(clauseBranch);
-
+
string? right = this.Visit(context.right);
if (right == null)
throw new CompilerException("Right operand for logical OR was not an expression.");
-
- this.Instruction($"cmp {right}, 0");
+
+ this.Instruction($"cmp {right}, 0", "compare result from second operand to 0");
this.Instruction("not");
- this.Instruction("mov LX, V0");
+ this.Instruction("mov LX, V0", "store second operand result");
this.Label(endBranch);
return "V0";
@@ -213,8 +298,8 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
public override string? VisitGreaterThanOrEqualExpression(CGrammarParser.GreaterThanOrEqualExpressionContext context)
{
BaseBinaryOperation(context.left, context.right, "cmp", "equality check");
- string endBranch = this.GetBranchLabel("end");
-
+ string endBranch = this.GenerateBranchLabel("end");
+
this.Instruction("bz");
this.Instruction($"jmp {endBranch}");
this.Instruction($"gt V0, V1");
@@ -225,8 +310,8 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
public override string? VisitLessThanOrEqualExpression(CGrammarParser.LessThanOrEqualExpressionContext context)
{
BaseBinaryOperation(context.left, context.right, "cmp", "equality check");
- string endBranch = this.GetBranchLabel("end");
-
+ string endBranch = this.GenerateBranchLabel("end");
+
this.Instruction("bz");
this.Instruction($"jmp {endBranch}");
this.Instruction($"lt V0, V1");
@@ -249,4 +334,272 @@ public class CCompilerVisitor : CGrammarBaseVisitor<string?>
this.BaseBinaryOperation(context.left, context.right, "and", "and");
return "DX";
}
+ public override string? VisitBitwiseLeftShiftExpression(CGrammarParser.BitwiseLeftShiftExpressionContext context)
+ {
+ this.BaseBinaryOperation(context.left, context.right, "shl", "left shift");
+ return "DX";
+ }
+ public override string? VisitBitwiseRightShiftExpression(CGrammarParser.BitwiseRightShiftExpressionContext context)
+ {
+ this.BaseBinaryOperation(context.left, context.right, "shr", "right shift");
+ return "DX";
+ }
+
+ public override string? VisitVariableDeclaration(CGrammarParser.VariableDeclarationContext context)
+ {
+ int addr = this.Alloc(2);
+ string name = context.name.Text;
+
+ Dictionary<string, int> scope = this._variableStack.Peek();
+ if (scope.ContainsKey(name))
+ throw new CompilerException($"Variable {name} already exists in current scope.");
+
+ scope[name] = addr;
+ if (context.value != null)
+ {
+ string? initialValue = this.Visit(context.value)
+ ?? throw new CompilerException("Initial variable definition value was not an expression");
+ this.Instruction($"mov {initialValue}, [${addr:X4}]", $"int {name} = {initialValue}");
+ }
+ else
+ this.Instruction($"mov 0, [${addr:X4}]", $"int {name}");
+
+ return null;
+ }
+ public override string? VisitVariableExpression(CGrammarParser.VariableExpressionContext context)
+ {
+ string varName = context.ID().GetText();
+ int addr = this.FindVariable(varName);
+
+ return $"[${addr:X4}]";
+ }
+
+ public override string? VisitVariableTarget(CGrammarParser.VariableTargetContext context)
+ {
+ string varName = context.ID().GetText();
+ int addr = this.FindVariable(varName);
+
+ return $"[${addr:X4}]";
+ }
+ public override string? VisitAssignmentExpression(CGrammarParser.AssignmentExpressionContext context)
+ {
+ string? target = this.Visit(context.target());
+ string? value = this.Visit(context.expression());
+
+ this.Instruction($"mov {value}, {target}");
+ return target;
+ }
+
+ public override string? VisitCompoundAddExpression(CGrammarParser.CompoundAddExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "add",
+ "addition",
+ "AX");
+ }
+ public override string? VisitCompoundSubtractExpression(CGrammarParser.CompoundSubtractExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "sub",
+ "subtraction",
+ "AX");
+ }
+ public override string? VisitCompoundMultiplyExpression(CGrammarParser.CompoundMultiplyExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "mult",
+ "multiplication",
+ "AX");
+ }
+ public override string? VisitCompoundDivideExpression(CGrammarParser.CompoundDivideExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "div",
+ "division",
+ "AX");
+ }
+ public override string? VisitCompoundModulusExpression(CGrammarParser.CompoundModulusExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "mod",
+ "modulus",
+ "AX");
+ }
+
+ public override string? VisitCompoundBitwiseOrExpression(CGrammarParser.CompoundBitwiseOrExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "or",
+ "or",
+ "DX");
+ }
+ public override string? VisitCompoundBitwiseXorExpression(CGrammarParser.CompoundBitwiseXorExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "xor",
+ "exclusive or",
+ "DX");
+ }
+ public override string? VisitCompoundBitwiseAndExpression(CGrammarParser.CompoundBitwiseAndExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "and",
+ "and",
+ "DX");
+ }
+
+ public override string? VisitCompoundBitwiseLeftShiftExpression(CGrammarParser.CompoundBitwiseLeftShiftExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "shl",
+ "left shift",
+ "DX");
+ }
+ public override string? VisitCompoundBitwiseRightShiftExpression(CGrammarParser.CompoundBitwiseRightShiftExpressionContext context)
+ {
+ return BaseBinaryCompoundOperation(context.target(),
+ context.expression(),
+ "shr",
+ "right shift",
+ "DX");
+ }
+
+ public override string? VisitIncrementPrefixExpression(CGrammarParser.IncrementPrefixExpressionContext context)
+ {
+ string target = this.Visit(context.target())
+ ?? throw new CompilerException("Increment target was not an expression");
+ this.Instruction($"inc {target}", "++i");
+ return target;
+ }
+ public override string? VisitDecrementPrefixExpression(CGrammarParser.DecrementPrefixExpressionContext context)
+ {
+ string target = this.Visit(context.target())
+ ?? throw new CompilerException("Decrement target was not an expression");
+ this.Instruction($"dec {target}", "--i");
+ return target;
+ }
+ public override string? VisitIncrementPostfixExpression(CGrammarParser.IncrementPostfixExpressionContext context)
+ {
+ string target = this.Visit(context.target())
+ ?? throw new CompilerException("Increment target was not an expression");
+ this.Instruction($"push {target}", "i++");
+ this.Instruction($"inc {target}");
+ this.Instruction("pop V0");
+ return "V0";
+ }
+ public override string? VisitDecrementPostfixExpression(CGrammarParser.DecrementPostfixExpressionContext context)
+ {
+ string target = this.Visit(context.target())
+ ?? throw new CompilerException("Decrement target was not an expression");
+ this.Instruction($"push {target}", "i--");
+ this.Instruction($"dec {target}");
+ this.Instruction($"pop V0");
+ return "V0";
+ }
+
+ public override string? VisitCommaExpression(CGrammarParser.CommaExpressionContext context)
+ {
+ this.Visit(context.left);
+ return this.Visit(context.right);
+ }
+
+ public override string? VisitTernaryExpression(CGrammarParser.TernaryExpressionContext context)
+ {
+ string cond = this.Visit(context.cond)
+ ?? throw new CompilerException("Ternary condition was not an expression");
+
+ string thenBranch = this.GenerateBranchLabel("then");
+ string endBranch = this.GenerateBranchLabel("end");
+ string result;
+
+ // Else branch is first since it saves us from having to perform a NOT operation.
+ // If cond, jump to then, else fall through to else, then jump to end
+
+ this.Instruction($"bz {cond}", "check ternary condition");
+ this.Instruction($"jmp {thenBranch}");
+
+ result = this.Visit(context.@else)
+ ?? throw new CompilerException("Else branch was not an expression");
+ this.Instruction($"mov {result}, V0", "store ternary fail result");
+ this.Instruction($"jmp {endBranch}");
+
+ this.Label(thenBranch);
+ result = this.Visit(context.then)
+ ?? throw new CompilerException("Else branch was not an expression");
+ this.Instruction($"mov {result}, V0", "store ternary success result");
+
+ this.Label(endBranch);
+
+ return "V0";
+ }
+
+ public override string? VisitIfStatement(CGrammarParser.IfStatementContext context)
+ {
+ string cond = this.Visit(context.expression())
+ ?? throw new CompilerException("If condition was not an expression");
+
+ // Else branch is first since it saves us from having to perform a NOT operation.
+ // If cond, jump to then, else fall through to else, then jump to end
+
+ string thenBranch = this.GenerateBranchLabel("then");
+ string endBranch = this.GenerateBranchLabel("end");
+
+ this.Instruction($"bz {cond}", "check if condition");
+ this.Instruction($"jmp {thenBranch}");
+
+ this.GeneratedComment("if failed");
+ if (context.@else != null)
+ this.Visit(context.@else);
+ this.Instruction($"jmp {endBranch}");
+
+ this.Label(thenBranch, "if succeeded");
+ this.Visit(context.then);
+
+ this.Label(endBranch);
+
+ return null;
+ }
+
+ public override string? VisitErrorNode(IErrorNode node)
+ {
+ if (node.Symbol.Type == CGrammarParser.COMMENT)
+ {
+ // strip // and \n and whitespace
+ string comment = node.Symbol.Text
+ .TrimStart("//").TrimEnd('\n').Trim();
+
+ this.UserComment(comment);
+ }
+
+ return base.VisitErrorNode(node);
+ }
+
+ public override string? Visit(IParseTree tree)
+ {
+ return base.Visit(tree);
+ }
+
+ /// <summary>
+ /// Basically identical to base version, except calls Visit on each child, making Visit not redundant.
+ /// </summary>
+ public override string? VisitChildren(IRuleNode node)
+ {
+ string? result = this.DefaultResult;
+ int childCount = node.ChildCount;
+ for (int i = 0; i < childCount && this.ShouldVisitNextChild(node, result); ++i)
+ {
+ string? nextResult = this.Visit(node.GetChild(i));
+ result = this.AggregateResult(result, nextResult);
+ }
+ return result;
+ }
} \ No newline at end of file
diff --git a/Compiler/CGrammar.g4 b/Compiler/CGrammar.g4
index 69b2c0a..aec4694 100644
--- a/Compiler/CGrammar.g4
+++ b/Compiler/CGrammar.g4
@@ -2,25 +2,57 @@ grammar CGrammar;
ID: [a-zA-Z_][a-zA-Z0-9_]*;
INT: [0-9]+;
+WS: [ \t\r\n]+ -> skip;
+COMMENT: '//' .*? ([\n] | EOF) -> channel(HIDDEN);
+
program
: function EOF
;
function
- : 'int' ID '(' ')' '{' statement* '}'
+ : 'int' name=ID '(' ')' block
+ ;
+
+body
+ : statement
+ | block
+ ;
+
+block
+ : '{' block_item* '}'
+ ;
+
+block_item
+ : statement
+ | declaration
;
statement
: 'return' expression ';' #returnStatement
+ | 'if' '(' expression ')' then=body ('else' else=body) #ifStatement
+ | expression #expressionStatement
+ ;
+
+
+declaration
+ : 'int' name=ID ('=' value=expression)? ';' #variableDeclaration
;
expression
: '(' expression ')' #parenthesizedExpression
+ | constant #constantExpression
+ | target '=' expression ';' #assignmentExpression
+ | ID #variableExpression
| '!' expression #notExpression
| '~' expression #invertExpression
+ | '++' target #incrementPrefixExpression
+ | '--' target #decrementPrefixExpression
+ | target '++' #incrementPostfixExpression
+ | target '--' #decrementPostfixExpression
+
| left=expression '*' right=expression #multiplyExpression
| left=expression '/' right=expression #divideExpression
| left=expression '%' right=expression #modulusExpression
@@ -39,12 +71,35 @@ expression
| left=expression '|' right=expression #bitwiseOrExpression
| left=expression '^' right=expression #bitwiseXorExpression
+ | left=expression '<<' right=expression #bitwiseLeftShiftExpression
+ | left=expression '>>' right=expression #bitwiseRightShiftExpression
+
| left=expression '&&' right=expression #logicalAndExpression
| left=expression '||' right=expression #logicalOrExpression
- | constant #constantExpression
+ | target '*=' expression #compoundMultiplyExpression
+ | target '/=' expression #compoundDivideExpression
+ | target '%=' expression #compoundModulusExpression
+
+ | target '+=' expression #compoundAddExpression
+ | target '-=' expression #compoundSubtractExpression
+
+ | target '&=' expression #compoundBitwiseAndExpression
+ | target '|=' expression #compoundBitwiseOrExpression
+ | target '^=' expression #compoundBitwiseXorExpression
+
+ | target '<<=' expression #compoundBitwiseLeftShiftExpression
+ | target '>>=' expression #compoundBitwiseRightShiftExpression
+
+ | left=expression ',' right=expression #commaExpression
+
+ | cond=expression '?' then=expression ':' else=expression #ternaryExpression
;
constant
: INT # intConstant
+ ;
+
+target
+ : ID # variableTarget
; \ No newline at end of file
diff --git a/Compiler/CommentCompilationMode.cs b/Compiler/CommentCompilationMode.cs
new file mode 100644
index 0000000..0ee20fd
--- /dev/null
+++ b/Compiler/CommentCompilationMode.cs
@@ -0,0 +1,10 @@
+namespace Q1.Compiler;
+
+[Flags]
+public enum CommentCompilationMode
+{
+ None = 0,
+ UserDefined = 1 << 0,
+ Generated = 1 << 1,
+ All = CommentCompilationMode.UserDefined | CommentCompilationMode.Generated
+} \ No newline at end of file
diff --git a/Compiler/Compiler.csproj b/Compiler/Compiler.csproj
index 042331e..623282e 100644
--- a/Compiler/Compiler.csproj
+++ b/Compiler/Compiler.csproj
@@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
- <Folder Include="gen\" />
+ <ProjectReference Include="..\Emulator\Emulator.csproj" />
</ItemGroup>
</Project>
diff --git a/Compiler/CompilerExtensions.cs b/Compiler/CompilerExtensions.cs
new file mode 100644
index 0000000..f1f0ee6
--- /dev/null
+++ b/Compiler/CompilerExtensions.cs
@@ -0,0 +1,12 @@
+namespace Q1.Compiler;
+
+public static class CompilerExtensions
+{
+ public static string TrimStart(this string source, string search)
+ {
+ if (source.StartsWith(search))
+ return source[search.Length..];
+
+ return source;
+ }
+} \ No newline at end of file
diff --git a/Compiler/Options.cs b/Compiler/CompilerOptions.cs
index c12a4c6..c1f5c3a 100644
--- a/Compiler/Options.cs
+++ b/Compiler/CompilerOptions.cs
@@ -2,11 +2,14 @@ namespace Q1.Compiler;
using CommandLine;
-public class Options
+public class CompilerOptions
{
[Option('i', "input", Required = true, HelpText = "Input file to compile.")]
public string InputFile { get; set; }
[Option('o', "output", Required = true, HelpText = "Output file to write the compiled code.")]
public string OutputFile { get; set; }
+
+ [Option('c', "comment-compilation", Required = false, HelpText = "Comments to preserve in the compiled result")]
+ public CommentCompilationMode CommentCompilationMode { get; set; } = CommentCompilationMode.UserDefined;
} \ No newline at end of file
diff --git a/Compiler/Program.cs b/Compiler/Program.cs
index b832a53..fdd8722 100644
--- a/Compiler/Program.cs
+++ b/Compiler/Program.cs
@@ -8,10 +8,16 @@ class Program
{
static void Main(string[] args)
{
- Parser.Default.ParseArguments<Options>(args).WithParsed(Program.Main);
+ Parser commandLineParser = new(with =>
+ {
+ with.CaseInsensitiveEnumValues = true;
+ });
+
+ commandLineParser.ParseArguments<CompilerOptions>(args)
+ .WithParsed(Program.Main);
}
- static void Main(Options options)
+ static void Main(CompilerOptions options)
{
Environment.CurrentDirectory = Path.GetDirectoryName(options.InputFile) ?? Environment.CurrentDirectory;
options.InputFile = Path.GetFileName(options.InputFile);
@@ -20,12 +26,13 @@ class Program
CGrammarLexer lexer = new(inputStream);
lexer.RemoveErrorListeners();
- CommonTokenStream tokenStream = new(lexer);
+ ITokenStream tokenStream = new BufferedTokenStream(lexer);
CGrammarParser parser = new(tokenStream);
parser.RemoveErrorListeners();
- CCompilerVisitor compiler = new();
- var result = compiler.Compile(parser.program());
+ CCompilerVisitor compiler = new(options.CommentCompilationMode);
+ IEnumerable<string> result = compiler.Compile(parser.program());
+
File.WriteAllLines(options.OutputFile, result);
}
} \ No newline at end of file
diff --git a/Compiler/gen/CGrammar.interp b/Compiler/gen/CGrammar.interp
index d5453b2..7d5c6e5 100644
--- a/Compiler/gen/CGrammar.interp
+++ b/Compiler/gen/CGrammar.interp
@@ -7,8 +7,13 @@ null
'}'
'return'
';'
+'if'
+'else'
+'='
'!'
'~'
+'++'
+'--'
'*'
'/'
'%'
@@ -23,8 +28,25 @@ null
'&'
'|'
'^'
+'<<'
+'>>'
'&&'
'||'
+'*='
+'/='
+'%='
+'+='
+'-='
+'&='
+'|='
+'^='
+'<<='
+'>>='
+','
+'?'
+':'
+null
+null
null
null
@@ -55,16 +77,43 @@ null
null
null
null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
ID
INT
+WS
+COMMENT
rule names:
program
function
+body
+block
+block_item
statement
+declaration
expression
constant
+target
atn:
-[4, 1, 27, 98, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 20, 8, 1, 10, 1, 12, 1, 23, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 41, 8, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 91, 8, 3, 10, 3, 12, 3, 94, 9, 3, 1, 4, 1, 4, 1, 4, 0, 1, 6, 5, 0, 2, 4, 6, 8, 0, 0, 112, 0, 10, 1, 0, 0, 0, 2, 13, 1, 0, 0, 0, 4, 26, 1, 0, 0, 0, 6, 40, 1, 0, 0, 0, 8, 95, 1, 0, 0, 0, 10, 11, 3, 2, 1, 0, 11, 12, 5, 0, 0, 1, 12, 1, 1, 0, 0, 0, 13, 14, 5, 1, 0, 0, 14, 15, 5, 26, 0, 0, 15, 16, 5, 2, 0, 0, 16, 17, 5, 3, 0, 0, 17, 21, 5, 4, 0, 0, 18, 20, 3, 4, 2, 0, 19, 18, 1, 0, 0, 0, 20, 23, 1, 0, 0, 0, 21, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 24, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 24, 25, 5, 5, 0, 0, 25, 3, 1, 0, 0, 0, 26, 27, 5, 6, 0, 0, 27, 28, 3, 6, 3, 0, 28, 29, 5, 7, 0, 0, 29, 5, 1, 0, 0, 0, 30, 31, 6, 3, -1, 0, 31, 32, 5, 2, 0, 0, 32, 33, 3, 6, 3, 0, 33, 34, 5, 3, 0, 0, 34, 41, 1, 0, 0, 0, 35, 36, 5, 8, 0, 0, 36, 41, 3, 6, 3, 19, 37, 38, 5, 9, 0, 0, 38, 41, 3, 6, 3, 18, 39, 41, 3, 8, 4, 0, 40, 30, 1, 0, 0, 0, 40, 35, 1, 0, 0, 0, 40, 37, 1, 0, 0, 0, 40, 39, 1, 0, 0, 0, 41, 92, 1, 0, 0, 0, 42, 43, 10, 17, 0, 0, 43, 44, 5, 10, 0, 0, 44, 91, 3, 6, 3, 18, 45, 46, 10, 16, 0, 0, 46, 47, 5, 11, 0, 0, 47, 91, 3, 6, 3, 17, 48, 49, 10, 15, 0, 0, 49, 50, 5, 12, 0, 0, 50, 91, 3, 6, 3, 16, 51, 52, 10, 14, 0, 0, 52, 53, 5, 13, 0, 0, 53, 91, 3, 6, 3, 15, 54, 55, 10, 13, 0, 0, 55, 56, 5, 14, 0, 0, 56, 91, 3, 6, 3, 14, 57, 58, 10, 12, 0, 0, 58, 59, 5, 15, 0, 0, 59, 91, 3, 6, 3, 13, 60, 61, 10, 11, 0, 0, 61, 62, 5, 16, 0, 0, 62, 91, 3, 6, 3, 12, 63, 64, 10, 10, 0, 0, 64, 65, 5, 17, 0, 0, 65, 91, 3, 6, 3, 11, 66, 67, 10, 9, 0, 0, 67, 68, 5, 18, 0, 0, 68, 91, 3, 6, 3, 10, 69, 70, 10, 8, 0, 0, 70, 71, 5, 19, 0, 0, 71, 91, 3, 6, 3, 9, 72, 73, 10, 7, 0, 0, 73, 74, 5, 20, 0, 0, 74, 91, 3, 6, 3, 8, 75, 76, 10, 6, 0, 0, 76, 77, 5, 21, 0, 0, 77, 91, 3, 6, 3, 7, 78, 79, 10, 5, 0, 0, 79, 80, 5, 22, 0, 0, 80, 91, 3, 6, 3, 6, 81, 82, 10, 4, 0, 0, 82, 83, 5, 23, 0, 0, 83, 91, 3, 6, 3, 5, 84, 85, 10, 3, 0, 0, 85, 86, 5, 24, 0, 0, 86, 91, 3, 6, 3, 4, 87, 88, 10, 2, 0, 0, 88, 89, 5, 25, 0, 0, 89, 91, 3, 6, 3, 3, 90, 42, 1, 0, 0, 0, 90, 45, 1, 0, 0, 0, 90, 48, 1, 0, 0, 0, 90, 51, 1, 0, 0, 0, 90, 54, 1, 0, 0, 0, 90, 57, 1, 0, 0, 0, 90, 60, 1, 0, 0, 0, 90, 63, 1, 0, 0, 0, 90, 66, 1, 0, 0, 0, 90, 69, 1, 0, 0, 0, 90, 72, 1, 0, 0, 0, 90, 75, 1, 0, 0, 0, 90, 78, 1, 0, 0, 0, 90, 81, 1, 0, 0, 0, 90, 84, 1, 0, 0, 0, 90, 87, 1, 0, 0, 0, 91, 94, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 7, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 95, 96, 5, 27, 0, 0, 96, 9, 1, 0, 0, 0, 4, 21, 40, 90, 92] \ No newline at end of file
+[4, 1, 49, 210, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 2, 32, 8, 2, 1, 3, 1, 3, 5, 3, 36, 8, 3, 10, 3, 12, 3, 39, 9, 3, 1, 3, 1, 3, 1, 4, 1, 4, 3, 4, 45, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 60, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 66, 8, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 136, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 201, 8, 7, 10, 7, 12, 7, 204, 9, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 0, 1, 14, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 0, 244, 0, 20, 1, 0, 0, 0, 2, 23, 1, 0, 0, 0, 4, 31, 1, 0, 0, 0, 6, 33, 1, 0, 0, 0, 8, 44, 1, 0, 0, 0, 10, 59, 1, 0, 0, 0, 12, 61, 1, 0, 0, 0, 14, 135, 1, 0, 0, 0, 16, 205, 1, 0, 0, 0, 18, 207, 1, 0, 0, 0, 20, 21, 3, 2, 1, 0, 21, 22, 5, 0, 0, 1, 22, 1, 1, 0, 0, 0, 23, 24, 5, 1, 0, 0, 24, 25, 5, 46, 0, 0, 25, 26, 5, 2, 0, 0, 26, 27, 5, 3, 0, 0, 27, 28, 3, 6, 3, 0, 28, 3, 1, 0, 0, 0, 29, 32, 3, 10, 5, 0, 30, 32, 3, 6, 3, 0, 31, 29, 1, 0, 0, 0, 31, 30, 1, 0, 0, 0, 32, 5, 1, 0, 0, 0, 33, 37, 5, 4, 0, 0, 34, 36, 3, 8, 4, 0, 35, 34, 1, 0, 0, 0, 36, 39, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 40, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 40, 41, 5, 5, 0, 0, 41, 7, 1, 0, 0, 0, 42, 45, 3, 10, 5, 0, 43, 45, 3, 12, 6, 0, 44, 42, 1, 0, 0, 0, 44, 43, 1, 0, 0, 0, 45, 9, 1, 0, 0, 0, 46, 47, 5, 6, 0, 0, 47, 48, 3, 14, 7, 0, 48, 49, 5, 7, 0, 0, 49, 60, 1, 0, 0, 0, 50, 51, 5, 8, 0, 0, 51, 52, 5, 2, 0, 0, 52, 53, 3, 14, 7, 0, 53, 54, 5, 3, 0, 0, 54, 55, 3, 4, 2, 0, 55, 56, 5, 9, 0, 0, 56, 57, 3, 4, 2, 0, 57, 60, 1, 0, 0, 0, 58, 60, 3, 14, 7, 0, 59, 46, 1, 0, 0, 0, 59, 50, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 11, 1, 0, 0, 0, 61, 62, 5, 1, 0, 0, 62, 65, 5, 46, 0, 0, 63, 64, 5, 10, 0, 0, 64, 66, 3, 14, 7, 0, 65, 63, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 68, 5, 7, 0, 0, 68, 13, 1, 0, 0, 0, 69, 70, 6, 7, -1, 0, 70, 71, 5, 2, 0, 0, 71, 72, 3, 14, 7, 0, 72, 73, 5, 3, 0, 0, 73, 136, 1, 0, 0, 0, 74, 136, 3, 16, 8, 0, 75, 76, 3, 18, 9, 0, 76, 77, 5, 10, 0, 0, 77, 78, 3, 14, 7, 0, 78, 79, 5, 7, 0, 0, 79, 136, 1, 0, 0, 0, 80, 136, 5, 46, 0, 0, 81, 82, 5, 11, 0, 0, 82, 136, 3, 14, 7, 36, 83, 84, 5, 12, 0, 0, 84, 136, 3, 14, 7, 35, 85, 86, 5, 13, 0, 0, 86, 136, 3, 18, 9, 0, 87, 88, 5, 14, 0, 0, 88, 136, 3, 18, 9, 0, 89, 90, 3, 18, 9, 0, 90, 91, 5, 13, 0, 0, 91, 136, 1, 0, 0, 0, 92, 93, 3, 18, 9, 0, 93, 94, 5, 14, 0, 0, 94, 136, 1, 0, 0, 0, 95, 96, 3, 18, 9, 0, 96, 97, 5, 33, 0, 0, 97, 98, 3, 14, 7, 12, 98, 136, 1, 0, 0, 0, 99, 100, 3, 18, 9, 0, 100, 101, 5, 34, 0, 0, 101, 102, 3, 14, 7, 11, 102, 136, 1, 0, 0, 0, 103, 104, 3, 18, 9, 0, 104, 105, 5, 35, 0, 0, 105, 106, 3, 14, 7, 10, 106, 136, 1, 0, 0, 0, 107, 108, 3, 18, 9, 0, 108, 109, 5, 36, 0, 0, 109, 110, 3, 14, 7, 9, 110, 136, 1, 0, 0, 0, 111, 112, 3, 18, 9, 0, 112, 113, 5, 37, 0, 0, 113, 114, 3, 14, 7, 8, 114, 136, 1, 0, 0, 0, 115, 116, 3, 18, 9, 0, 116, 117, 5, 38, 0, 0, 117, 118, 3, 14, 7, 7, 118, 136, 1, 0, 0, 0, 119, 120, 3, 18, 9, 0, 120, 121, 5, 39, 0, 0, 121, 122, 3, 14, 7, 6, 122, 136, 1, 0, 0, 0, 123, 124, 3, 18, 9, 0, 124, 125, 5, 40, 0, 0, 125, 126, 3, 14, 7, 5, 126, 136, 1, 0, 0, 0, 127, 128, 3, 18, 9, 0, 128, 129, 5, 41, 0, 0, 129, 130, 3, 14, 7, 4, 130, 136, 1, 0, 0, 0, 131, 132, 3, 18, 9, 0, 132, 133, 5, 42, 0, 0, 133, 134, 3, 14, 7, 3, 134, 136, 1, 0, 0, 0, 135, 69, 1, 0, 0, 0, 135, 74, 1, 0, 0, 0, 135, 75, 1, 0, 0, 0, 135, 80, 1, 0, 0, 0, 135, 81, 1, 0, 0, 0, 135, 83, 1, 0, 0, 0, 135, 85, 1, 0, 0, 0, 135, 87, 1, 0, 0, 0, 135, 89, 1, 0, 0, 0, 135, 92, 1, 0, 0, 0, 135, 95, 1, 0, 0, 0, 135, 99, 1, 0, 0, 0, 135, 103, 1, 0, 0, 0, 135, 107, 1, 0, 0, 0, 135, 111, 1, 0, 0, 0, 135, 115, 1, 0, 0, 0, 135, 119, 1, 0, 0, 0, 135, 123, 1, 0, 0, 0, 135, 127, 1, 0, 0, 0, 135, 131, 1, 0, 0, 0, 136, 202, 1, 0, 0, 0, 137, 138, 10, 30, 0, 0, 138, 139, 5, 15, 0, 0, 139, 201, 3, 14, 7, 31, 140, 141, 10, 29, 0, 0, 141, 142, 5, 16, 0, 0, 142, 201, 3, 14, 7, 30, 143, 144, 10, 28, 0, 0, 144, 145, 5, 17, 0, 0, 145, 201, 3, 14, 7, 29, 146, 147, 10, 27, 0, 0, 147, 148, 5, 18, 0, 0, 148, 201, 3, 14, 7, 28, 149, 150, 10, 26, 0, 0, 150, 151, 5, 19, 0, 0, 151, 201, 3, 14, 7, 27, 152, 153, 10, 25, 0, 0, 153, 154, 5, 20, 0, 0, 154, 201, 3, 14, 7, 26, 155, 156, 10, 24, 0, 0, 156, 157, 5, 21, 0, 0, 157, 201, 3, 14, 7, 25, 158, 159, 10, 23, 0, 0, 159, 160, 5, 22, 0, 0, 160, 201, 3, 14, 7, 24, 161, 162, 10, 22, 0, 0, 162, 163, 5, 23, 0, 0, 163, 201, 3, 14, 7, 23, 164, 165, 10, 21, 0, 0, 165, 166, 5, 24, 0, 0, 166, 201, 3, 14, 7, 22, 167, 168, 10, 20, 0, 0, 168, 169, 5, 25, 0, 0, 169, 201, 3, 14, 7, 21, 170, 171, 10, 19, 0, 0, 171, 172, 5, 26, 0, 0, 172, 201, 3, 14, 7, 20, 173, 174, 10, 18, 0, 0, 174, 175, 5, 27, 0, 0, 175, 201, 3, 14, 7, 19, 176, 177, 10, 17, 0, 0, 177, 178, 5, 28, 0, 0, 178, 201, 3, 14, 7, 18, 179, 180, 10, 16, 0, 0, 180, 181, 5, 29, 0, 0, 181, 201, 3, 14, 7, 17, 182, 183, 10, 15, 0, 0, 183, 184, 5, 30, 0, 0, 184, 201, 3, 14, 7, 16, 185, 186, 10, 14, 0, 0, 186, 187, 5, 31, 0, 0, 187, 201, 3, 14, 7, 15, 188, 189, 10, 13, 0, 0, 189, 190, 5, 32, 0, 0, 190, 201, 3, 14, 7, 14, 191, 192, 10, 2, 0, 0, 192, 193, 5, 43, 0, 0, 193, 201, 3, 14, 7, 3, 194, 195, 10, 1, 0, 0, 195, 196, 5, 44, 0, 0, 196, 197, 3, 14, 7, 0, 197, 198, 5, 45, 0, 0, 198, 199, 3, 14, 7, 2, 199, 201, 1, 0, 0, 0, 200, 137, 1, 0, 0, 0, 200, 140, 1, 0, 0, 0, 200, 143, 1, 0, 0, 0, 200, 146, 1, 0, 0, 0, 200, 149, 1, 0, 0, 0, 200, 152, 1, 0, 0, 0, 200, 155, 1, 0, 0, 0, 200, 158, 1, 0, 0, 0, 200, 161, 1, 0, 0, 0, 200, 164, 1, 0, 0, 0, 200, 167, 1, 0, 0, 0, 200, 170, 1, 0, 0, 0, 200, 173, 1, 0, 0, 0, 200, 176, 1, 0, 0, 0, 200, 179, 1, 0, 0, 0, 200, 182, 1, 0, 0, 0, 200, 185, 1, 0, 0, 0, 200, 188, 1, 0, 0, 0, 200, 191, 1, 0, 0, 0, 200, 194, 1, 0, 0, 0, 201, 204, 1, 0, 0, 0, 202, 200, 1, 0, 0, 0, 202, 203, 1, 0, 0, 0, 203, 15, 1, 0, 0, 0, 204, 202, 1, 0, 0, 0, 205, 206, 5, 47, 0, 0, 206, 17, 1, 0, 0, 0, 207, 208, 5, 46, 0, 0, 208, 19, 1, 0, 0, 0, 8, 31, 37, 44, 59, 65, 135, 200, 202] \ No newline at end of file
diff --git a/Compiler/gen/CGrammar.tokens b/Compiler/gen/CGrammar.tokens
index fc1a392..7556128 100644
--- a/Compiler/gen/CGrammar.tokens
+++ b/Compiler/gen/CGrammar.tokens
@@ -23,8 +23,30 @@ T__21=22
T__22=23
T__23=24
T__24=25
-ID=26
-INT=27
+T__25=26
+T__26=27
+T__27=28
+T__28=29
+T__29=30
+T__30=31
+T__31=32
+T__32=33
+T__33=34
+T__34=35
+T__35=36
+T__36=37
+T__37=38
+T__38=39
+T__39=40
+T__40=41
+T__41=42
+T__42=43
+T__43=44
+T__44=45
+ID=46
+INT=47
+WS=48
+COMMENT=49
'int'=1
'('=2
')'=3
@@ -32,21 +54,41 @@ INT=27
'}'=5
'return'=6
';'=7
-'!'=8
-'~'=9
-'*'=10
-'/'=11
-'%'=12
-'+'=13
-'-'=14
-'<'=15
-'>'=16
-'<='=17
-'>='=18
-'=='=19
-'!='=20
-'&'=21
-'|'=22
-'^'=23
-'&&'=24
-'||'=25
+'if'=8
+'else'=9
+'='=10
+'!'=11
+'~'=12
+'++'=13
+'--'=14
+'*'=15
+'/'=16
+'%'=17
+'+'=18
+'-'=19
+'<'=20
+'>'=21
+'<='=22
+'>='=23
+'=='=24
+'!='=25
+'&'=26
+'|'=27
+'^'=28
+'<<'=29
+'>>'=30
+'&&'=31
+'||'=32
+'*='=33
+'/='=34
+'%='=35
+'+='=36
+'-='=37
+'&='=38
+'|='=39
+'^='=40
+'<<='=41
+'>>='=42
+','=43
+'?'=44
+':'=45
diff --git a/Compiler/gen/CGrammarBaseVisitor.cs b/Compiler/gen/CGrammarBaseVisitor.cs
index 1f864c3..704cdd1 100644
--- a/Compiler/gen/CGrammarBaseVisitor.cs
+++ b/Compiler/gen/CGrammarBaseVisitor.cs
@@ -55,6 +55,36 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitFunction([NotNull] CGrammarParser.FunctionContext context) { return VisitChildren(context); }
/// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.body"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitBody([NotNull] CGrammarParser.BodyContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.block"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitBlock([NotNull] CGrammarParser.BlockContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.block_item"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitBlock_item([NotNull] CGrammarParser.Block_itemContext context) { return VisitChildren(context); }
+ /// <summary>
/// Visit a parse tree produced by the <c>returnStatement</c>
/// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// <para>
@@ -66,8 +96,8 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitReturnStatement([NotNull] CGrammarParser.ReturnStatementContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>bitwiseXorExpression</c>
- /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// Visit a parse tree produced by the <c>ifStatement</c>
+ /// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
@@ -75,10 +105,10 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitBitwiseXorExpression([NotNull] CGrammarParser.BitwiseXorExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitIfStatement([NotNull] CGrammarParser.IfStatementContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>constantExpression</c>
- /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// Visit a parse tree produced by the <c>expressionStatement</c>
+ /// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
@@ -86,9 +116,20 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitConstantExpression([NotNull] CGrammarParser.ConstantExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitExpressionStatement([NotNull] CGrammarParser.ExpressionStatementContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>lessThanOrEqualExpression</c>
+ /// Visit a parse tree produced by the <c>variableDeclaration</c>
+ /// labeled alternative in <see cref="CGrammarParser.declaration"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitVariableDeclaration([NotNull] CGrammarParser.VariableDeclarationContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundSubtractExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -97,7 +138,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitLessThanOrEqualExpression([NotNull] CGrammarParser.LessThanOrEqualExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitCompoundSubtractExpression([NotNull] CGrammarParser.CompoundSubtractExpressionContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>modulusExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -121,7 +162,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitNotExpression([NotNull] CGrammarParser.NotExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>notEqualExpression</c>
+ /// Visit a parse tree produced by the <c>decrementPrefixExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -130,7 +171,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitNotEqualExpression([NotNull] CGrammarParser.NotEqualExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitDecrementPrefixExpression([NotNull] CGrammarParser.DecrementPrefixExpressionContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>multiplyExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -154,7 +195,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitGreaterThanExpression([NotNull] CGrammarParser.GreaterThanExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>logicalOrExpression</c>
+ /// Visit a parse tree produced by the <c>bitwiseLeftShiftExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -163,9 +204,9 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitLogicalOrExpression([NotNull] CGrammarParser.LogicalOrExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitBitwiseLeftShiftExpression([NotNull] CGrammarParser.BitwiseLeftShiftExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>greaterThanOrEqualExpression</c>
+ /// Visit a parse tree produced by the <c>bitwiseRightShiftExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -174,9 +215,9 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitGreaterThanOrEqualExpression([NotNull] CGrammarParser.GreaterThanOrEqualExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitBitwiseRightShiftExpression([NotNull] CGrammarParser.BitwiseRightShiftExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>divideExpression</c>
+ /// Visit a parse tree produced by the <c>variableExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -185,9 +226,9 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitDivideExpression([NotNull] CGrammarParser.DivideExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitVariableExpression([NotNull] CGrammarParser.VariableExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>bitwiseOrExpression</c>
+ /// Visit a parse tree produced by the <c>compoundDivideExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -196,7 +237,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitBitwiseOrExpression([NotNull] CGrammarParser.BitwiseOrExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitCompoundDivideExpression([NotNull] CGrammarParser.CompoundDivideExpressionContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>parenthesizedExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -209,7 +250,7 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitParenthesizedExpression([NotNull] CGrammarParser.ParenthesizedExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>addExpression</c>
+ /// Visit a parse tree produced by the <c>compoundAddExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -218,9 +259,9 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitAddExpression([NotNull] CGrammarParser.AddExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitCompoundAddExpression([NotNull] CGrammarParser.CompoundAddExpressionContext context) { return VisitChildren(context); }
/// <summary>
- /// Visit a parse tree produced by the <c>subtractExpression</c>
+ /// Visit a parse tree produced by the <c>compoundMultiplyExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -229,7 +270,18 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- public virtual Result VisitSubtractExpression([NotNull] CGrammarParser.SubtractExpressionContext context) { return VisitChildren(context); }
+ public virtual Result VisitCompoundMultiplyExpression([NotNull] CGrammarParser.CompoundMultiplyExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseXorExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundBitwiseXorExpression([NotNull] CGrammarParser.CompoundBitwiseXorExpressionContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>bitwiseAndExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -286,6 +338,237 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <return>The visitor result.</return>
public virtual Result VisitEqualExpression([NotNull] CGrammarParser.EqualExpressionContext context) { return VisitChildren(context); }
/// <summary>
+ /// Visit a parse tree produced by the <c>bitwiseXorExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitBitwiseXorExpression([NotNull] CGrammarParser.BitwiseXorExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>constantExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitConstantExpression([NotNull] CGrammarParser.ConstantExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundModulusExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundModulusExpression([NotNull] CGrammarParser.CompoundModulusExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>lessThanOrEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitLessThanOrEqualExpression([NotNull] CGrammarParser.LessThanOrEqualExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>incrementPostfixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitIncrementPostfixExpression([NotNull] CGrammarParser.IncrementPostfixExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseRightShiftExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundBitwiseRightShiftExpression([NotNull] CGrammarParser.CompoundBitwiseRightShiftExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>assignmentExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitAssignmentExpression([NotNull] CGrammarParser.AssignmentExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>notEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitNotEqualExpression([NotNull] CGrammarParser.NotEqualExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseAndExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundBitwiseAndExpression([NotNull] CGrammarParser.CompoundBitwiseAndExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>logicalOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitLogicalOrExpression([NotNull] CGrammarParser.LogicalOrExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>commaExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCommaExpression([NotNull] CGrammarParser.CommaExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>incrementPrefixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitIncrementPrefixExpression([NotNull] CGrammarParser.IncrementPrefixExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>greaterThanOrEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitGreaterThanOrEqualExpression([NotNull] CGrammarParser.GreaterThanOrEqualExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>divideExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitDivideExpression([NotNull] CGrammarParser.DivideExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>bitwiseOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitBitwiseOrExpression([NotNull] CGrammarParser.BitwiseOrExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>addExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitAddExpression([NotNull] CGrammarParser.AddExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>subtractExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitSubtractExpression([NotNull] CGrammarParser.SubtractExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundBitwiseOrExpression([NotNull] CGrammarParser.CompoundBitwiseOrExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>decrementPostfixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitDecrementPostfixExpression([NotNull] CGrammarParser.DecrementPostfixExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>ternaryExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitTernaryExpression([NotNull] CGrammarParser.TernaryExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseLeftShiftExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitCompoundBitwiseLeftShiftExpression([NotNull] CGrammarParser.CompoundBitwiseLeftShiftExpressionContext context) { return VisitChildren(context); }
+ /// <summary>
/// Visit a parse tree produced by the <c>intConstant</c>
/// labeled alternative in <see cref="CGrammarParser.constant"/>.
/// <para>
@@ -296,4 +579,15 @@ public partial class CGrammarBaseVisitor<Result> : AbstractParseTreeVisitor<Resu
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitIntConstant([NotNull] CGrammarParser.IntConstantContext context) { return VisitChildren(context); }
+ /// <summary>
+ /// Visit a parse tree produced by the <c>variableTarget</c>
+ /// labeled alternative in <see cref="CGrammarParser.target"/>.
+ /// <para>
+ /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
+ /// on <paramref name="context"/>.
+ /// </para>
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ public virtual Result VisitVariableTarget([NotNull] CGrammarParser.VariableTargetContext context) { return VisitChildren(context); }
}
diff --git a/Compiler/gen/CGrammarLexer.cs b/Compiler/gen/CGrammarLexer.cs
index 3bb49f2..8d6ed18 100644
--- a/Compiler/gen/CGrammarLexer.cs
+++ b/Compiler/gen/CGrammarLexer.cs
@@ -36,7 +36,10 @@ public partial class CGrammarLexer : Lexer {
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
- T__24=25, ID=26, INT=27;
+ T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
+ T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38,
+ T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45,
+ ID=46, INT=47, WS=48, COMMENT=49;
public static string[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@@ -49,7 +52,9 @@ public partial class CGrammarLexer : Lexer {
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
- "ID", "INT"
+ "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
+ "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40",
+ "T__41", "T__42", "T__43", "T__44", "ID", "INT", "WS", "COMMENT"
};
@@ -63,14 +68,18 @@ public partial class CGrammarLexer : Lexer {
}
private static readonly string[] _LiteralNames = {
- null, "'int'", "'('", "')'", "'{'", "'}'", "'return'", "';'", "'!'", "'~'",
- "'*'", "'/'", "'%'", "'+'", "'-'", "'<'", "'>'", "'<='", "'>='", "'=='",
- "'!='", "'&'", "'|'", "'^'", "'&&'", "'||'"
+ null, "'int'", "'('", "')'", "'{'", "'}'", "'return'", "';'", "'if'",
+ "'else'", "'='", "'!'", "'~'", "'++'", "'--'", "'*'", "'/'", "'%'", "'+'",
+ "'-'", "'<'", "'>'", "'<='", "'>='", "'=='", "'!='", "'&'", "'|'", "'^'",
+ "'<<'", "'>>'", "'&&'", "'||'", "'*='", "'/='", "'%='", "'+='", "'-='",
+ "'&='", "'|='", "'^='", "'<<='", "'>>='", "','", "'?'", "':'"
};
private static readonly string[] _SymbolicNames = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
- null, null, "ID", "INT"
+ null, null, null, null, null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null, null, null, "ID", "INT",
+ "WS", "COMMENT"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@@ -100,46 +109,87 @@ public partial class CGrammarLexer : Lexer {
}
}
private static int[] _serializedATN = {
- 4,0,27,130,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
+ 4,0,49,255,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,
7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,
- 7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,1,0,1,0,1,0,1,0,
- 1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,
- 7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,
- 1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,
- 1,20,1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,
- 5,25,121,8,25,10,25,12,25,124,9,25,1,26,4,26,127,8,26,11,26,12,26,128,
- 0,0,27,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,
- 27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,
- 51,26,53,27,1,0,3,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,
- 1,0,48,57,131,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,
- 0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,
- 21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,
- 0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,
- 0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,
- 1,0,0,0,1,55,1,0,0,0,3,59,1,0,0,0,5,61,1,0,0,0,7,63,1,0,0,0,9,65,1,0,0,
- 0,11,67,1,0,0,0,13,74,1,0,0,0,15,76,1,0,0,0,17,78,1,0,0,0,19,80,1,0,0,
- 0,21,82,1,0,0,0,23,84,1,0,0,0,25,86,1,0,0,0,27,88,1,0,0,0,29,90,1,0,0,
- 0,31,92,1,0,0,0,33,94,1,0,0,0,35,97,1,0,0,0,37,100,1,0,0,0,39,103,1,0,
- 0,0,41,106,1,0,0,0,43,108,1,0,0,0,45,110,1,0,0,0,47,112,1,0,0,0,49,115,
- 1,0,0,0,51,118,1,0,0,0,53,126,1,0,0,0,55,56,5,105,0,0,56,57,5,110,0,0,
- 57,58,5,116,0,0,58,2,1,0,0,0,59,60,5,40,0,0,60,4,1,0,0,0,61,62,5,41,0,
- 0,62,6,1,0,0,0,63,64,5,123,0,0,64,8,1,0,0,0,65,66,5,125,0,0,66,10,1,0,
- 0,0,67,68,5,114,0,0,68,69,5,101,0,0,69,70,5,116,0,0,70,71,5,117,0,0,71,
- 72,5,114,0,0,72,73,5,110,0,0,73,12,1,0,0,0,74,75,5,59,0,0,75,14,1,0,0,
- 0,76,77,5,33,0,0,77,16,1,0,0,0,78,79,5,126,0,0,79,18,1,0,0,0,80,81,5,42,
- 0,0,81,20,1,0,0,0,82,83,5,47,0,0,83,22,1,0,0,0,84,85,5,37,0,0,85,24,1,
- 0,0,0,86,87,5,43,0,0,87,26,1,0,0,0,88,89,5,45,0,0,89,28,1,0,0,0,90,91,
- 5,60,0,0,91,30,1,0,0,0,92,93,5,62,0,0,93,32,1,0,0,0,94,95,5,60,0,0,95,
- 96,5,61,0,0,96,34,1,0,0,0,97,98,5,62,0,0,98,99,5,61,0,0,99,36,1,0,0,0,
- 100,101,5,61,0,0,101,102,5,61,0,0,102,38,1,0,0,0,103,104,5,33,0,0,104,
- 105,5,61,0,0,105,40,1,0,0,0,106,107,5,38,0,0,107,42,1,0,0,0,108,109,5,
- 124,0,0,109,44,1,0,0,0,110,111,5,94,0,0,111,46,1,0,0,0,112,113,5,38,0,
- 0,113,114,5,38,0,0,114,48,1,0,0,0,115,116,5,124,0,0,116,117,5,124,0,0,
- 117,50,1,0,0,0,118,122,7,0,0,0,119,121,7,1,0,0,120,119,1,0,0,0,121,124,
- 1,0,0,0,122,120,1,0,0,0,122,123,1,0,0,0,123,52,1,0,0,0,124,122,1,0,0,0,
- 125,127,7,2,0,0,126,125,1,0,0,0,127,128,1,0,0,0,128,126,1,0,0,0,128,129,
- 1,0,0,0,129,54,1,0,0,0,3,0,122,128,0
+ 7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,
+ 7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,
+ 7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,
+ 7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,1,0,1,
+ 0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,
+ 1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,
+ 12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,
+ 18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,21,1,22,1,22,1,22,1,23,1,23,1,
+ 23,1,24,1,24,1,24,1,25,1,25,1,26,1,26,1,27,1,27,1,28,1,28,1,28,1,29,1,
+ 29,1,29,1,30,1,30,1,30,1,31,1,31,1,31,1,32,1,32,1,32,1,33,1,33,1,33,1,
+ 34,1,34,1,34,1,35,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,37,1,38,1,38,1,
+ 38,1,39,1,39,1,39,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,41,1,42,1,42,1,
+ 43,1,43,1,44,1,44,1,45,1,45,5,45,225,8,45,10,45,12,45,228,9,45,1,46,4,
+ 46,231,8,46,11,46,12,46,232,1,47,4,47,236,8,47,11,47,12,47,237,1,47,1,
+ 47,1,48,1,48,1,48,1,48,5,48,246,8,48,10,48,12,48,249,9,48,1,48,3,48,252,
+ 8,48,1,48,1,48,1,247,0,49,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,
+ 21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,
+ 45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,
+ 69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,
+ 93,47,95,48,97,49,1,0,5,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,
+ 122,1,0,48,57,3,0,9,10,13,13,32,32,1,1,10,10,258,0,1,1,0,0,0,0,3,1,0,0,
+ 0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,
+ 0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,
+ 0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,
+ 1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,
+ 0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,
+ 1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,
+ 0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,
+ 1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,
+ 0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,1,99,1,0,0,0,3,103,1,0,0,0,5,
+ 105,1,0,0,0,7,107,1,0,0,0,9,109,1,0,0,0,11,111,1,0,0,0,13,118,1,0,0,0,
+ 15,120,1,0,0,0,17,123,1,0,0,0,19,128,1,0,0,0,21,130,1,0,0,0,23,132,1,0,
+ 0,0,25,134,1,0,0,0,27,137,1,0,0,0,29,140,1,0,0,0,31,142,1,0,0,0,33,144,
+ 1,0,0,0,35,146,1,0,0,0,37,148,1,0,0,0,39,150,1,0,0,0,41,152,1,0,0,0,43,
+ 154,1,0,0,0,45,157,1,0,0,0,47,160,1,0,0,0,49,163,1,0,0,0,51,166,1,0,0,
+ 0,53,168,1,0,0,0,55,170,1,0,0,0,57,172,1,0,0,0,59,175,1,0,0,0,61,178,1,
+ 0,0,0,63,181,1,0,0,0,65,184,1,0,0,0,67,187,1,0,0,0,69,190,1,0,0,0,71,193,
+ 1,0,0,0,73,196,1,0,0,0,75,199,1,0,0,0,77,202,1,0,0,0,79,205,1,0,0,0,81,
+ 208,1,0,0,0,83,212,1,0,0,0,85,216,1,0,0,0,87,218,1,0,0,0,89,220,1,0,0,
+ 0,91,222,1,0,0,0,93,230,1,0,0,0,95,235,1,0,0,0,97,241,1,0,0,0,99,100,5,
+ 105,0,0,100,101,5,110,0,0,101,102,5,116,0,0,102,2,1,0,0,0,103,104,5,40,
+ 0,0,104,4,1,0,0,0,105,106,5,41,0,0,106,6,1,0,0,0,107,108,5,123,0,0,108,
+ 8,1,0,0,0,109,110,5,125,0,0,110,10,1,0,0,0,111,112,5,114,0,0,112,113,5,
+ 101,0,0,113,114,5,116,0,0,114,115,5,117,0,0,115,116,5,114,0,0,116,117,
+ 5,110,0,0,117,12,1,0,0,0,118,119,5,59,0,0,119,14,1,0,0,0,120,121,5,105,
+ 0,0,121,122,5,102,0,0,122,16,1,0,0,0,123,124,5,101,0,0,124,125,5,108,0,
+ 0,125,126,5,115,0,0,126,127,5,101,0,0,127,18,1,0,0,0,128,129,5,61,0,0,
+ 129,20,1,0,0,0,130,131,5,33,0,0,131,22,1,0,0,0,132,133,5,126,0,0,133,24,
+ 1,0,0,0,134,135,5,43,0,0,135,136,5,43,0,0,136,26,1,0,0,0,137,138,5,45,
+ 0,0,138,139,5,45,0,0,139,28,1,0,0,0,140,141,5,42,0,0,141,30,1,0,0,0,142,
+ 143,5,47,0,0,143,32,1,0,0,0,144,145,5,37,0,0,145,34,1,0,0,0,146,147,5,
+ 43,0,0,147,36,1,0,0,0,148,149,5,45,0,0,149,38,1,0,0,0,150,151,5,60,0,0,
+ 151,40,1,0,0,0,152,153,5,62,0,0,153,42,1,0,0,0,154,155,5,60,0,0,155,156,
+ 5,61,0,0,156,44,1,0,0,0,157,158,5,62,0,0,158,159,5,61,0,0,159,46,1,0,0,
+ 0,160,161,5,61,0,0,161,162,5,61,0,0,162,48,1,0,0,0,163,164,5,33,0,0,164,
+ 165,5,61,0,0,165,50,1,0,0,0,166,167,5,38,0,0,167,52,1,0,0,0,168,169,5,
+ 124,0,0,169,54,1,0,0,0,170,171,5,94,0,0,171,56,1,0,0,0,172,173,5,60,0,
+ 0,173,174,5,60,0,0,174,58,1,0,0,0,175,176,5,62,0,0,176,177,5,62,0,0,177,
+ 60,1,0,0,0,178,179,5,38,0,0,179,180,5,38,0,0,180,62,1,0,0,0,181,182,5,
+ 124,0,0,182,183,5,124,0,0,183,64,1,0,0,0,184,185,5,42,0,0,185,186,5,61,
+ 0,0,186,66,1,0,0,0,187,188,5,47,0,0,188,189,5,61,0,0,189,68,1,0,0,0,190,
+ 191,5,37,0,0,191,192,5,61,0,0,192,70,1,0,0,0,193,194,5,43,0,0,194,195,
+ 5,61,0,0,195,72,1,0,0,0,196,197,5,45,0,0,197,198,5,61,0,0,198,74,1,0,0,
+ 0,199,200,5,38,0,0,200,201,5,61,0,0,201,76,1,0,0,0,202,203,5,124,0,0,203,
+ 204,5,61,0,0,204,78,1,0,0,0,205,206,5,94,0,0,206,207,5,61,0,0,207,80,1,
+ 0,0,0,208,209,5,60,0,0,209,210,5,60,0,0,210,211,5,61,0,0,211,82,1,0,0,
+ 0,212,213,5,62,0,0,213,214,5,62,0,0,214,215,5,61,0,0,215,84,1,0,0,0,216,
+ 217,5,44,0,0,217,86,1,0,0,0,218,219,5,63,0,0,219,88,1,0,0,0,220,221,5,
+ 58,0,0,221,90,1,0,0,0,222,226,7,0,0,0,223,225,7,1,0,0,224,223,1,0,0,0,
+ 225,228,1,0,0,0,226,224,1,0,0,0,226,227,1,0,0,0,227,92,1,0,0,0,228,226,
+ 1,0,0,0,229,231,7,2,0,0,230,229,1,0,0,0,231,232,1,0,0,0,232,230,1,0,0,
+ 0,232,233,1,0,0,0,233,94,1,0,0,0,234,236,7,3,0,0,235,234,1,0,0,0,236,237,
+ 1,0,0,0,237,235,1,0,0,0,237,238,1,0,0,0,238,239,1,0,0,0,239,240,6,47,0,
+ 0,240,96,1,0,0,0,241,242,5,47,0,0,242,243,5,47,0,0,243,247,1,0,0,0,244,
+ 246,9,0,0,0,245,244,1,0,0,0,246,249,1,0,0,0,247,248,1,0,0,0,247,245,1,
+ 0,0,0,248,251,1,0,0,0,249,247,1,0,0,0,250,252,7,4,0,0,251,250,1,0,0,0,
+ 252,253,1,0,0,0,253,254,6,48,1,0,254,98,1,0,0,0,6,0,226,232,237,247,251,
+ 2,6,0,0,0,1,0
};
public static readonly ATN _ATN =
diff --git a/Compiler/gen/CGrammarLexer.interp b/Compiler/gen/CGrammarLexer.interp
index d041f13..faa747d 100644
--- a/Compiler/gen/CGrammarLexer.interp
+++ b/Compiler/gen/CGrammarLexer.interp
@@ -7,8 +7,13 @@ null
'}'
'return'
';'
+'if'
+'else'
+'='
'!'
'~'
+'++'
+'--'
'*'
'/'
'%'
@@ -23,8 +28,25 @@ null
'&'
'|'
'^'
+'<<'
+'>>'
'&&'
'||'
+'*='
+'/='
+'%='
+'+='
+'-='
+'&='
+'|='
+'^='
+'<<='
+'>>='
+','
+'?'
+':'
+null
+null
null
null
@@ -55,8 +77,30 @@ null
null
null
null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
+null
ID
INT
+WS
+COMMENT
rule names:
T__0
@@ -84,8 +128,30 @@ T__21
T__22
T__23
T__24
+T__25
+T__26
+T__27
+T__28
+T__29
+T__30
+T__31
+T__32
+T__33
+T__34
+T__35
+T__36
+T__37
+T__38
+T__39
+T__40
+T__41
+T__42
+T__43
+T__44
ID
INT
+WS
+COMMENT
channel names:
DEFAULT_TOKEN_CHANNEL
@@ -95,4 +161,4 @@ mode names:
DEFAULT_MODE
atn:
-[4, 0, 27, 130, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 121, 8, 25, 10, 25, 12, 25, 124, 9, 25, 1, 26, 4, 26, 127, 8, 26, 11, 26, 12, 26, 128, 0, 0, 27, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 1, 0, 3, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 1, 0, 48, 57, 131, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 1, 55, 1, 0, 0, 0, 3, 59, 1, 0, 0, 0, 5, 61, 1, 0, 0, 0, 7, 63, 1, 0, 0, 0, 9, 65, 1, 0, 0, 0, 11, 67, 1, 0, 0, 0, 13, 74, 1, 0, 0, 0, 15, 76, 1, 0, 0, 0, 17, 78, 1, 0, 0, 0, 19, 80, 1, 0, 0, 0, 21, 82, 1, 0, 0, 0, 23, 84, 1, 0, 0, 0, 25, 86, 1, 0, 0, 0, 27, 88, 1, 0, 0, 0, 29, 90, 1, 0, 0, 0, 31, 92, 1, 0, 0, 0, 33, 94, 1, 0, 0, 0, 35, 97, 1, 0, 0, 0, 37, 100, 1, 0, 0, 0, 39, 103, 1, 0, 0, 0, 41, 106, 1, 0, 0, 0, 43, 108, 1, 0, 0, 0, 45, 110, 1, 0, 0, 0, 47, 112, 1, 0, 0, 0, 49, 115, 1, 0, 0, 0, 51, 118, 1, 0, 0, 0, 53, 126, 1, 0, 0, 0, 55, 56, 5, 105, 0, 0, 56, 57, 5, 110, 0, 0, 57, 58, 5, 116, 0, 0, 58, 2, 1, 0, 0, 0, 59, 60, 5, 40, 0, 0, 60, 4, 1, 0, 0, 0, 61, 62, 5, 41, 0, 0, 62, 6, 1, 0, 0, 0, 63, 64, 5, 123, 0, 0, 64, 8, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0, 66, 10, 1, 0, 0, 0, 67, 68, 5, 114, 0, 0, 68, 69, 5, 101, 0, 0, 69, 70, 5, 116, 0, 0, 70, 71, 5, 117, 0, 0, 71, 72, 5, 114, 0, 0, 72, 73, 5, 110, 0, 0, 73, 12, 1, 0, 0, 0, 74, 75, 5, 59, 0, 0, 75, 14, 1, 0, 0, 0, 76, 77, 5, 33, 0, 0, 77, 16, 1, 0, 0, 0, 78, 79, 5, 126, 0, 0, 79, 18, 1, 0, 0, 0, 80, 81, 5, 42, 0, 0, 81, 20, 1, 0, 0, 0, 82, 83, 5, 47, 0, 0, 83, 22, 1, 0, 0, 0, 84, 85, 5, 37, 0, 0, 85, 24, 1, 0, 0, 0, 86, 87, 5, 43, 0, 0, 87, 26, 1, 0, 0, 0, 88, 89, 5, 45, 0, 0, 89, 28, 1, 0, 0, 0, 90, 91, 5, 60, 0, 0, 91, 30, 1, 0, 0, 0, 92, 93, 5, 62, 0, 0, 93, 32, 1, 0, 0, 0, 94, 95, 5, 60, 0, 0, 95, 96, 5, 61, 0, 0, 96, 34, 1, 0, 0, 0, 97, 98, 5, 62, 0, 0, 98, 99, 5, 61, 0, 0, 99, 36, 1, 0, 0, 0, 100, 101, 5, 61, 0, 0, 101, 102, 5, 61, 0, 0, 102, 38, 1, 0, 0, 0, 103, 104, 5, 33, 0, 0, 104, 105, 5, 61, 0, 0, 105, 40, 1, 0, 0, 0, 106, 107, 5, 38, 0, 0, 107, 42, 1, 0, 0, 0, 108, 109, 5, 124, 0, 0, 109, 44, 1, 0, 0, 0, 110, 111, 5, 94, 0, 0, 111, 46, 1, 0, 0, 0, 112, 113, 5, 38, 0, 0, 113, 114, 5, 38, 0, 0, 114, 48, 1, 0, 0, 0, 115, 116, 5, 124, 0, 0, 116, 117, 5, 124, 0, 0, 117, 50, 1, 0, 0, 0, 118, 122, 7, 0, 0, 0, 119, 121, 7, 1, 0, 0, 120, 119, 1, 0, 0, 0, 121, 124, 1, 0, 0, 0, 122, 120, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 52, 1, 0, 0, 0, 124, 122, 1, 0, 0, 0, 125, 127, 7, 2, 0, 0, 126, 125, 1, 0, 0, 0, 127, 128, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 128, 129, 1, 0, 0, 0, 129, 54, 1, 0, 0, 0, 3, 0, 122, 128, 0] \ No newline at end of file
+[4, 0, 49, 255, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 44, 1, 44, 1, 45, 1, 45, 5, 45, 225, 8, 45, 10, 45, 12, 45, 228, 9, 45, 1, 46, 4, 46, 231, 8, 46, 11, 46, 12, 46, 232, 1, 47, 4, 47, 236, 8, 47, 11, 47, 12, 47, 237, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 5, 48, 246, 8, 48, 10, 48, 12, 48, 249, 9, 48, 1, 48, 3, 48, 252, 8, 48, 1, 48, 1, 48, 1, 247, 0, 49, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 48, 97, 49, 1, 0, 5, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 1, 1, 10, 10, 258, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 1, 99, 1, 0, 0, 0, 3, 103, 1, 0, 0, 0, 5, 105, 1, 0, 0, 0, 7, 107, 1, 0, 0, 0, 9, 109, 1, 0, 0, 0, 11, 111, 1, 0, 0, 0, 13, 118, 1, 0, 0, 0, 15, 120, 1, 0, 0, 0, 17, 123, 1, 0, 0, 0, 19, 128, 1, 0, 0, 0, 21, 130, 1, 0, 0, 0, 23, 132, 1, 0, 0, 0, 25, 134, 1, 0, 0, 0, 27, 137, 1, 0, 0, 0, 29, 140, 1, 0, 0, 0, 31, 142, 1, 0, 0, 0, 33, 144, 1, 0, 0, 0, 35, 146, 1, 0, 0, 0, 37, 148, 1, 0, 0, 0, 39, 150, 1, 0, 0, 0, 41, 152, 1, 0, 0, 0, 43, 154, 1, 0, 0, 0, 45, 157, 1, 0, 0, 0, 47, 160, 1, 0, 0, 0, 49, 163, 1, 0, 0, 0, 51, 166, 1, 0, 0, 0, 53, 168, 1, 0, 0, 0, 55, 170, 1, 0, 0, 0, 57, 172, 1, 0, 0, 0, 59, 175, 1, 0, 0, 0, 61, 178, 1, 0, 0, 0, 63, 181, 1, 0, 0, 0, 65, 184, 1, 0, 0, 0, 67, 187, 1, 0, 0, 0, 69, 190, 1, 0, 0, 0, 71, 193, 1, 0, 0, 0, 73, 196, 1, 0, 0, 0, 75, 199, 1, 0, 0, 0, 77, 202, 1, 0, 0, 0, 79, 205, 1, 0, 0, 0, 81, 208, 1, 0, 0, 0, 83, 212, 1, 0, 0, 0, 85, 216, 1, 0, 0, 0, 87, 218, 1, 0, 0, 0, 89, 220, 1, 0, 0, 0, 91, 222, 1, 0, 0, 0, 93, 230, 1, 0, 0, 0, 95, 235, 1, 0, 0, 0, 97, 241, 1, 0, 0, 0, 99, 100, 5, 105, 0, 0, 100, 101, 5, 110, 0, 0, 101, 102, 5, 116, 0, 0, 102, 2, 1, 0, 0, 0, 103, 104, 5, 40, 0, 0, 104, 4, 1, 0, 0, 0, 105, 106, 5, 41, 0, 0, 106, 6, 1, 0, 0, 0, 107, 108, 5, 123, 0, 0, 108, 8, 1, 0, 0, 0, 109, 110, 5, 125, 0, 0, 110, 10, 1, 0, 0, 0, 111, 112, 5, 114, 0, 0, 112, 113, 5, 101, 0, 0, 113, 114, 5, 116, 0, 0, 114, 115, 5, 117, 0, 0, 115, 116, 5, 114, 0, 0, 116, 117, 5, 110, 0, 0, 117, 12, 1, 0, 0, 0, 118, 119, 5, 59, 0, 0, 119, 14, 1, 0, 0, 0, 120, 121, 5, 105, 0, 0, 121, 122, 5, 102, 0, 0, 122, 16, 1, 0, 0, 0, 123, 124, 5, 101, 0, 0, 124, 125, 5, 108, 0, 0, 125, 126, 5, 115, 0, 0, 126, 127, 5, 101, 0, 0, 127, 18, 1, 0, 0, 0, 128, 129, 5, 61, 0, 0, 129, 20, 1, 0, 0, 0, 130, 131, 5, 33, 0, 0, 131, 22, 1, 0, 0, 0, 132, 133, 5, 126, 0, 0, 133, 24, 1, 0, 0, 0, 134, 135, 5, 43, 0, 0, 135, 136, 5, 43, 0, 0, 136, 26, 1, 0, 0, 0, 137, 138, 5, 45, 0, 0, 138, 139, 5, 45, 0, 0, 139, 28, 1, 0, 0, 0, 140, 141, 5, 42, 0, 0, 141, 30, 1, 0, 0, 0, 142, 143, 5, 47, 0, 0, 143, 32, 1, 0, 0, 0, 144, 145, 5, 37, 0, 0, 145, 34, 1, 0, 0, 0, 146, 147, 5, 43, 0, 0, 147, 36, 1, 0, 0, 0, 148, 149, 5, 45, 0, 0, 149, 38, 1, 0, 0, 0, 150, 151, 5, 60, 0, 0, 151, 40, 1, 0, 0, 0, 152, 153, 5, 62, 0, 0, 153, 42, 1, 0, 0, 0, 154, 155, 5, 60, 0, 0, 155, 156, 5, 61, 0, 0, 156, 44, 1, 0, 0, 0, 157, 158, 5, 62, 0, 0, 158, 159, 5, 61, 0, 0, 159, 46, 1, 0, 0, 0, 160, 161, 5, 61, 0, 0, 161, 162, 5, 61, 0, 0, 162, 48, 1, 0, 0, 0, 163, 164, 5, 33, 0, 0, 164, 165, 5, 61, 0, 0, 165, 50, 1, 0, 0, 0, 166, 167, 5, 38, 0, 0, 167, 52, 1, 0, 0, 0, 168, 169, 5, 124, 0, 0, 169, 54, 1, 0, 0, 0, 170, 171, 5, 94, 0, 0, 171, 56, 1, 0, 0, 0, 172, 173, 5, 60, 0, 0, 173, 174, 5, 60, 0, 0, 174, 58, 1, 0, 0, 0, 175, 176, 5, 62, 0, 0, 176, 177, 5, 62, 0, 0, 177, 60, 1, 0, 0, 0, 178, 179, 5, 38, 0, 0, 179, 180, 5, 38, 0, 0, 180, 62, 1, 0, 0, 0, 181, 182, 5, 124, 0, 0, 182, 183, 5, 124, 0, 0, 183, 64, 1, 0, 0, 0, 184, 185, 5, 42, 0, 0, 185, 186, 5, 61, 0, 0, 186, 66, 1, 0, 0, 0, 187, 188, 5, 47, 0, 0, 188, 189, 5, 61, 0, 0, 189, 68, 1, 0, 0, 0, 190, 191, 5, 37, 0, 0, 191, 192, 5, 61, 0, 0, 192, 70, 1, 0, 0, 0, 193, 194, 5, 43, 0, 0, 194, 195, 5, 61, 0, 0, 195, 72, 1, 0, 0, 0, 196, 197, 5, 45, 0, 0, 197, 198, 5, 61, 0, 0, 198, 74, 1, 0, 0, 0, 199, 200, 5, 38, 0, 0, 200, 201, 5, 61, 0, 0, 201, 76, 1, 0, 0, 0, 202, 203, 5, 124, 0, 0, 203, 204, 5, 61, 0, 0, 204, 78, 1, 0, 0, 0, 205, 206, 5, 94, 0, 0, 206, 207, 5, 61, 0, 0, 207, 80, 1, 0, 0, 0, 208, 209, 5, 60, 0, 0, 209, 210, 5, 60, 0, 0, 210, 211, 5, 61, 0, 0, 211, 82, 1, 0, 0, 0, 212, 213, 5, 62, 0, 0, 213, 214, 5, 62, 0, 0, 214, 215, 5, 61, 0, 0, 215, 84, 1, 0, 0, 0, 216, 217, 5, 44, 0, 0, 217, 86, 1, 0, 0, 0, 218, 219, 5, 63, 0, 0, 219, 88, 1, 0, 0, 0, 220, 221, 5, 58, 0, 0, 221, 90, 1, 0, 0, 0, 222, 226, 7, 0, 0, 0, 223, 225, 7, 1, 0, 0, 224, 223, 1, 0, 0, 0, 225, 228, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 92, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 229, 231, 7, 2, 0, 0, 230, 229, 1, 0, 0, 0, 231, 232, 1, 0, 0, 0, 232, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 94, 1, 0, 0, 0, 234, 236, 7, 3, 0, 0, 235, 234, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 235, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 239, 1, 0, 0, 0, 239, 240, 6, 47, 0, 0, 240, 96, 1, 0, 0, 0, 241, 242, 5, 47, 0, 0, 242, 243, 5, 47, 0, 0, 243, 247, 1, 0, 0, 0, 244, 246, 9, 0, 0, 0, 245, 244, 1, 0, 0, 0, 246, 249, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 248, 251, 1, 0, 0, 0, 249, 247, 1, 0, 0, 0, 250, 252, 7, 4, 0, 0, 251, 250, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 254, 6, 48, 1, 0, 254, 98, 1, 0, 0, 0, 6, 0, 226, 232, 237, 247, 251, 2, 6, 0, 0, 0, 1, 0] \ No newline at end of file
diff --git a/Compiler/gen/CGrammarLexer.tokens b/Compiler/gen/CGrammarLexer.tokens
index fc1a392..7556128 100644
--- a/Compiler/gen/CGrammarLexer.tokens
+++ b/Compiler/gen/CGrammarLexer.tokens
@@ -23,8 +23,30 @@ T__21=22
T__22=23
T__23=24
T__24=25
-ID=26
-INT=27
+T__25=26
+T__26=27
+T__27=28
+T__28=29
+T__29=30
+T__30=31
+T__31=32
+T__32=33
+T__33=34
+T__34=35
+T__35=36
+T__36=37
+T__37=38
+T__38=39
+T__39=40
+T__40=41
+T__41=42
+T__42=43
+T__43=44
+T__44=45
+ID=46
+INT=47
+WS=48
+COMMENT=49
'int'=1
'('=2
')'=3
@@ -32,21 +54,41 @@ INT=27
'}'=5
'return'=6
';'=7
-'!'=8
-'~'=9
-'*'=10
-'/'=11
-'%'=12
-'+'=13
-'-'=14
-'<'=15
-'>'=16
-'<='=17
-'>='=18
-'=='=19
-'!='=20
-'&'=21
-'|'=22
-'^'=23
-'&&'=24
-'||'=25
+'if'=8
+'else'=9
+'='=10
+'!'=11
+'~'=12
+'++'=13
+'--'=14
+'*'=15
+'/'=16
+'%'=17
+'+'=18
+'-'=19
+'<'=20
+'>'=21
+'<='=22
+'>='=23
+'=='=24
+'!='=25
+'&'=26
+'|'=27
+'^'=28
+'<<'=29
+'>>'=30
+'&&'=31
+'||'=32
+'*='=33
+'/='=34
+'%='=35
+'+='=36
+'-='=37
+'&='=38
+'|='=39
+'^='=40
+'<<='=41
+'>>='=42
+','=43
+'?'=44
+':'=45
diff --git a/Compiler/gen/CGrammarParser.cs b/Compiler/gen/CGrammarParser.cs
index 88f1740..f0db2f0 100644
--- a/Compiler/gen/CGrammarParser.cs
+++ b/Compiler/gen/CGrammarParser.cs
@@ -39,23 +39,32 @@ public partial class CGrammarParser : Parser {
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
- T__24=25, ID=26, INT=27;
+ T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
+ T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38,
+ T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45,
+ ID=46, INT=47, WS=48, COMMENT=49;
public const int
- RULE_program = 0, RULE_function = 1, RULE_statement = 2, RULE_expression = 3,
- RULE_constant = 4;
+ RULE_program = 0, RULE_function = 1, RULE_body = 2, RULE_block = 3, RULE_block_item = 4,
+ RULE_statement = 5, RULE_declaration = 6, RULE_expression = 7, RULE_constant = 8,
+ RULE_target = 9;
public static readonly string[] ruleNames = {
- "program", "function", "statement", "expression", "constant"
+ "program", "function", "body", "block", "block_item", "statement", "declaration",
+ "expression", "constant", "target"
};
private static readonly string[] _LiteralNames = {
- null, "'int'", "'('", "')'", "'{'", "'}'", "'return'", "';'", "'!'", "'~'",
- "'*'", "'/'", "'%'", "'+'", "'-'", "'<'", "'>'", "'<='", "'>='", "'=='",
- "'!='", "'&'", "'|'", "'^'", "'&&'", "'||'"
+ null, "'int'", "'('", "')'", "'{'", "'}'", "'return'", "';'", "'if'",
+ "'else'", "'='", "'!'", "'~'", "'++'", "'--'", "'*'", "'/'", "'%'", "'+'",
+ "'-'", "'<'", "'>'", "'<='", "'>='", "'=='", "'!='", "'&'", "'|'", "'^'",
+ "'<<'", "'>>'", "'&&'", "'||'", "'*='", "'/='", "'%='", "'+='", "'-='",
+ "'&='", "'|='", "'^='", "'<<='", "'>>='", "','", "'?'", "':'"
};
private static readonly string[] _SymbolicNames = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
- null, null, "ID", "INT"
+ null, null, null, null, null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null, null, null, "ID", "INT",
+ "WS", "COMMENT"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@@ -114,9 +123,9 @@ public partial class CGrammarParser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
- State = 10;
+ State = 20;
function();
- State = 11;
+ State = 21;
Match(Eof);
}
}
@@ -132,13 +141,11 @@ public partial class CGrammarParser : Parser {
}
public partial class FunctionContext : ParserRuleContext {
- [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CGrammarParser.ID, 0); }
- [System.Diagnostics.DebuggerNonUserCode] public StatementContext[] statement() {
- return GetRuleContexts<StatementContext>();
- }
- [System.Diagnostics.DebuggerNonUserCode] public StatementContext statement(int i) {
- return GetRuleContext<StatementContext>(i);
+ public IToken name;
+ [System.Diagnostics.DebuggerNonUserCode] public BlockContext block() {
+ return GetRuleContext<BlockContext>(0);
}
+ [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CGrammarParser.ID, 0); }
public FunctionContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
{
@@ -156,35 +163,142 @@ public partial class CGrammarParser : Parser {
public FunctionContext function() {
FunctionContext _localctx = new FunctionContext(Context, State);
EnterRule(_localctx, 2, RULE_function);
- int _la;
try {
EnterOuterAlt(_localctx, 1);
{
- State = 13;
+ State = 23;
Match(T__0);
- State = 14;
- Match(ID);
- State = 15;
+ State = 24;
+ _localctx.name = Match(ID);
+ State = 25;
Match(T__1);
- State = 16;
+ State = 26;
Match(T__2);
- State = 17;
+ State = 27;
+ block();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ ErrorHandler.ReportError(this, re);
+ ErrorHandler.Recover(this, re);
+ }
+ finally {
+ ExitRule();
+ }
+ return _localctx;
+ }
+
+ public partial class BodyContext : ParserRuleContext {
+ [System.Diagnostics.DebuggerNonUserCode] public StatementContext statement() {
+ return GetRuleContext<StatementContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public BlockContext block() {
+ return GetRuleContext<BlockContext>(0);
+ }
+ public BodyContext(ParserRuleContext parent, int invokingState)
+ : base(parent, invokingState)
+ {
+ }
+ public override int RuleIndex { get { return RULE_body; } }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitBody(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+
+ [RuleVersion(0)]
+ public BodyContext body() {
+ BodyContext _localctx = new BodyContext(Context, State);
+ EnterRule(_localctx, 4, RULE_body);
+ try {
+ State = 31;
+ ErrorHandler.Sync(this);
+ switch (TokenStream.LA(1)) {
+ case T__1:
+ case T__5:
+ case T__7:
+ case T__10:
+ case T__11:
+ case T__12:
+ case T__13:
+ case ID:
+ case INT:
+ EnterOuterAlt(_localctx, 1);
+ {
+ State = 29;
+ statement();
+ }
+ break;
+ case T__3:
+ EnterOuterAlt(_localctx, 2);
+ {
+ State = 30;
+ block();
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ ErrorHandler.ReportError(this, re);
+ ErrorHandler.Recover(this, re);
+ }
+ finally {
+ ExitRule();
+ }
+ return _localctx;
+ }
+
+ public partial class BlockContext : ParserRuleContext {
+ [System.Diagnostics.DebuggerNonUserCode] public Block_itemContext[] block_item() {
+ return GetRuleContexts<Block_itemContext>();
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public Block_itemContext block_item(int i) {
+ return GetRuleContext<Block_itemContext>(i);
+ }
+ public BlockContext(ParserRuleContext parent, int invokingState)
+ : base(parent, invokingState)
+ {
+ }
+ public override int RuleIndex { get { return RULE_block; } }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitBlock(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+
+ [RuleVersion(0)]
+ public BlockContext block() {
+ BlockContext _localctx = new BlockContext(Context, State);
+ EnterRule(_localctx, 6, RULE_block);
+ int _la;
+ try {
+ EnterOuterAlt(_localctx, 1);
+ {
+ State = 33;
Match(T__3);
- State = 21;
+ State = 37;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
- while (_la==T__5) {
+ while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 211106232564038L) != 0)) {
{
{
- State = 18;
- statement();
+ State = 34;
+ block_item();
}
}
- State = 23;
+ State = 39;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
- State = 24;
+ State = 40;
Match(T__4);
}
}
@@ -199,6 +313,71 @@ public partial class CGrammarParser : Parser {
return _localctx;
}
+ public partial class Block_itemContext : ParserRuleContext {
+ [System.Diagnostics.DebuggerNonUserCode] public StatementContext statement() {
+ return GetRuleContext<StatementContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public DeclarationContext declaration() {
+ return GetRuleContext<DeclarationContext>(0);
+ }
+ public Block_itemContext(ParserRuleContext parent, int invokingState)
+ : base(parent, invokingState)
+ {
+ }
+ public override int RuleIndex { get { return RULE_block_item; } }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitBlock_item(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+
+ [RuleVersion(0)]
+ public Block_itemContext block_item() {
+ Block_itemContext _localctx = new Block_itemContext(Context, State);
+ EnterRule(_localctx, 8, RULE_block_item);
+ try {
+ State = 44;
+ ErrorHandler.Sync(this);
+ switch (TokenStream.LA(1)) {
+ case T__1:
+ case T__5:
+ case T__7:
+ case T__10:
+ case T__11:
+ case T__12:
+ case T__13:
+ case ID:
+ case INT:
+ EnterOuterAlt(_localctx, 1);
+ {
+ State = 42;
+ statement();
+ }
+ break;
+ case T__0:
+ EnterOuterAlt(_localctx, 2);
+ {
+ State = 43;
+ declaration();
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ ErrorHandler.ReportError(this, re);
+ ErrorHandler.Recover(this, re);
+ }
+ finally {
+ ExitRule();
+ }
+ return _localctx;
+ }
+
public partial class StatementContext : ParserRuleContext {
public StatementContext(ParserRuleContext parent, int invokingState)
: base(parent, invokingState)
@@ -211,6 +390,18 @@ public partial class CGrammarParser : Parser {
base.CopyFrom(context);
}
}
+ public partial class ExpressionStatementContext : StatementContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public ExpressionStatementContext(StatementContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitExpressionStatement(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
public partial class ReturnStatementContext : StatementContext {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
return GetRuleContext<ExpressionContext>(0);
@@ -223,20 +414,152 @@ public partial class CGrammarParser : Parser {
else return visitor.VisitChildren(this);
}
}
+ public partial class IfStatementContext : StatementContext {
+ public BodyContext then;
+ public BodyContext @else;
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public BodyContext[] body() {
+ return GetRuleContexts<BodyContext>();
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public BodyContext body(int i) {
+ return GetRuleContext<BodyContext>(i);
+ }
+ public IfStatementContext(StatementContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitIfStatement(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
[RuleVersion(0)]
public StatementContext statement() {
StatementContext _localctx = new StatementContext(Context, State);
- EnterRule(_localctx, 4, RULE_statement);
+ EnterRule(_localctx, 10, RULE_statement);
+ try {
+ State = 59;
+ ErrorHandler.Sync(this);
+ switch (TokenStream.LA(1)) {
+ case T__5:
+ _localctx = new ReturnStatementContext(_localctx);
+ EnterOuterAlt(_localctx, 1);
+ {
+ State = 46;
+ Match(T__5);
+ State = 47;
+ expression(0);
+ State = 48;
+ Match(T__6);
+ }
+ break;
+ case T__7:
+ _localctx = new IfStatementContext(_localctx);
+ EnterOuterAlt(_localctx, 2);
+ {
+ State = 50;
+ Match(T__7);
+ State = 51;
+ Match(T__1);
+ State = 52;
+ expression(0);
+ State = 53;
+ Match(T__2);
+ State = 54;
+ ((IfStatementContext)_localctx).then = body();
+ {
+ State = 55;
+ Match(T__8);
+ State = 56;
+ ((IfStatementContext)_localctx).@else = body();
+ }
+ }
+ break;
+ case T__1:
+ case T__10:
+ case T__11:
+ case T__12:
+ case T__13:
+ case ID:
+ case INT:
+ _localctx = new ExpressionStatementContext(_localctx);
+ EnterOuterAlt(_localctx, 3);
+ {
+ State = 58;
+ expression(0);
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ ErrorHandler.ReportError(this, re);
+ ErrorHandler.Recover(this, re);
+ }
+ finally {
+ ExitRule();
+ }
+ return _localctx;
+ }
+
+ public partial class DeclarationContext : ParserRuleContext {
+ public DeclarationContext(ParserRuleContext parent, int invokingState)
+ : base(parent, invokingState)
+ {
+ }
+ public override int RuleIndex { get { return RULE_declaration; } }
+
+ public DeclarationContext() { }
+ public virtual void CopyFrom(DeclarationContext context) {
+ base.CopyFrom(context);
+ }
+ }
+ public partial class VariableDeclarationContext : DeclarationContext {
+ public IToken name;
+ public ExpressionContext value;
+ [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CGrammarParser.ID, 0); }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public VariableDeclarationContext(DeclarationContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitVariableDeclaration(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+
+ [RuleVersion(0)]
+ public DeclarationContext declaration() {
+ DeclarationContext _localctx = new DeclarationContext(Context, State);
+ EnterRule(_localctx, 12, RULE_declaration);
+ int _la;
try {
- _localctx = new ReturnStatementContext(_localctx);
+ _localctx = new VariableDeclarationContext(_localctx);
EnterOuterAlt(_localctx, 1);
{
- State = 26;
- Match(T__5);
- State = 27;
- expression(0);
- State = 28;
+ State = 61;
+ Match(T__0);
+ State = 62;
+ ((VariableDeclarationContext)_localctx).name = Match(ID);
+ State = 65;
+ ErrorHandler.Sync(this);
+ _la = TokenStream.LA(1);
+ if (_la==T__9) {
+ {
+ State = 63;
+ Match(T__9);
+ State = 64;
+ ((VariableDeclarationContext)_localctx).value = expression(0);
+ }
+ }
+
+ State = 67;
Match(T__6);
}
}
@@ -263,7 +586,22 @@ public partial class CGrammarParser : Parser {
base.CopyFrom(context);
}
}
- public partial class BitwiseXorExpressionContext : ExpressionContext {
+ public partial class CompoundSubtractExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundSubtractExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundSubtractExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class ModulusExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -272,27 +610,39 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public BitwiseXorExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public ModulusExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitBitwiseXorExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitModulusExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class ConstantExpressionContext : ExpressionContext {
- [System.Diagnostics.DebuggerNonUserCode] public ConstantContext constant() {
- return GetRuleContext<ConstantContext>(0);
+ public partial class NotExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
}
- public ConstantExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public NotExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitConstantExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitNotExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class LessThanOrEqualExpressionContext : ExpressionContext {
+ public partial class DecrementPrefixExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ public DecrementPrefixExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitDecrementPrefixExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class MultiplyExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -301,15 +651,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public LessThanOrEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public MultiplyExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitLessThanOrEqualExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitMultiplyExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class ModulusExpressionContext : ExpressionContext {
+ public partial class GreaterThanExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -318,27 +668,131 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public ModulusExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public GreaterThanExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitModulusExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitGreaterThanExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class NotExpressionContext : ExpressionContext {
+ public partial class BitwiseLeftShiftExpressionContext : ExpressionContext {
+ public ExpressionContext left;
+ public ExpressionContext right;
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
+ return GetRuleContexts<ExpressionContext>();
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
+ return GetRuleContext<ExpressionContext>(i);
+ }
+ public BitwiseLeftShiftExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitBitwiseLeftShiftExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class BitwiseRightShiftExpressionContext : ExpressionContext {
+ public ExpressionContext left;
+ public ExpressionContext right;
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
+ return GetRuleContexts<ExpressionContext>();
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
+ return GetRuleContext<ExpressionContext>(i);
+ }
+ public BitwiseRightShiftExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitBitwiseRightShiftExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class VariableExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CGrammarParser.ID, 0); }
+ public VariableExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitVariableExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundDivideExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
return GetRuleContext<ExpressionContext>(0);
}
- public NotExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public CompoundDivideExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitNotExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitCompoundDivideExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class NotEqualExpressionContext : ExpressionContext {
+ public partial class ParenthesizedExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public ParenthesizedExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitParenthesizedExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundAddExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundAddExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundAddExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundMultiplyExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundMultiplyExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundMultiplyExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundBitwiseXorExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundBitwiseXorExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundBitwiseXorExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class BitwiseAndExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -347,15 +801,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public NotEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public BitwiseAndExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitNotEqualExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitBitwiseAndExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class MultiplyExpressionContext : ExpressionContext {
+ public partial class LessThanExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -364,15 +818,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public MultiplyExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public LessThanExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitMultiplyExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitLessThanExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class GreaterThanExpressionContext : ExpressionContext {
+ public partial class LogicalAndExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -381,15 +835,27 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public GreaterThanExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public LogicalAndExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitGreaterThanExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitLogicalAndExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class LogicalOrExpressionContext : ExpressionContext {
+ public partial class InvertExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public InvertExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitInvertExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class EqualExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -398,15 +864,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public LogicalOrExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public EqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitLogicalOrExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitEqualExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class GreaterThanOrEqualExpressionContext : ExpressionContext {
+ public partial class BitwiseXorExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -415,15 +881,42 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public GreaterThanOrEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public BitwiseXorExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitGreaterThanOrEqualExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitBitwiseXorExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class DivideExpressionContext : ExpressionContext {
+ public partial class ConstantExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ConstantContext constant() {
+ return GetRuleContext<ConstantContext>(0);
+ }
+ public ConstantExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitConstantExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundModulusExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundModulusExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundModulusExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class LessThanOrEqualExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -432,15 +925,57 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public DivideExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public LessThanOrEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitDivideExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitLessThanOrEqualExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class BitwiseOrExpressionContext : ExpressionContext {
+ public partial class IncrementPostfixExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ public IncrementPostfixExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitIncrementPostfixExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundBitwiseRightShiftExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundBitwiseRightShiftExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundBitwiseRightShiftExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class AssignmentExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public AssignmentExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitAssignmentExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class NotEqualExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -449,27 +984,30 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public BitwiseOrExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public NotEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitBitwiseOrExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitNotEqualExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class ParenthesizedExpressionContext : ExpressionContext {
+ public partial class CompoundBitwiseAndExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
return GetRuleContext<ExpressionContext>(0);
}
- public ParenthesizedExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public CompoundBitwiseAndExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitParenthesizedExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitCompoundBitwiseAndExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class AddExpressionContext : ExpressionContext {
+ public partial class LogicalOrExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -478,15 +1016,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public AddExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public LogicalOrExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitAddExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitLogicalOrExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class SubtractExpressionContext : ExpressionContext {
+ public partial class CommaExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -495,15 +1033,27 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public SubtractExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public CommaExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitSubtractExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitCommaExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class BitwiseAndExpressionContext : ExpressionContext {
+ public partial class IncrementPrefixExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ public IncrementPrefixExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitIncrementPrefixExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class GreaterThanOrEqualExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -512,15 +1062,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public BitwiseAndExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public GreaterThanOrEqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitBitwiseAndExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitGreaterThanOrEqualExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class LessThanExpressionContext : ExpressionContext {
+ public partial class DivideExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -529,15 +1079,15 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public LessThanExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public DivideExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitLessThanExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitDivideExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class LogicalAndExpressionContext : ExpressionContext {
+ public partial class BitwiseOrExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -546,27 +1096,32 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public LogicalAndExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public BitwiseOrExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitLogicalAndExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitBitwiseOrExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class InvertExpressionContext : ExpressionContext {
- [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
- return GetRuleContext<ExpressionContext>(0);
+ public partial class AddExpressionContext : ExpressionContext {
+ public ExpressionContext left;
+ public ExpressionContext right;
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
+ return GetRuleContexts<ExpressionContext>();
}
- public InvertExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
+ return GetRuleContext<ExpressionContext>(i);
+ }
+ public AddExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitInvertExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitAddExpression(this);
else return visitor.VisitChildren(this);
}
}
- public partial class EqualExpressionContext : ExpressionContext {
+ public partial class SubtractExpressionContext : ExpressionContext {
public ExpressionContext left;
public ExpressionContext right;
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
@@ -575,11 +1130,71 @@ public partial class CGrammarParser : Parser {
[System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
return GetRuleContext<ExpressionContext>(i);
}
- public EqualExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ public SubtractExpressionContext(ExpressionContext context) { CopyFrom(context); }
[System.Diagnostics.DebuggerNonUserCode]
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
- if (typedVisitor != null) return typedVisitor.VisitEqualExpression(this);
+ if (typedVisitor != null) return typedVisitor.VisitSubtractExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundBitwiseOrExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundBitwiseOrExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundBitwiseOrExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class DecrementPostfixExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ public DecrementPostfixExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitDecrementPostfixExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class TernaryExpressionContext : ExpressionContext {
+ public ExpressionContext cond;
+ public ExpressionContext then;
+ public ExpressionContext @else;
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() {
+ return GetRuleContexts<ExpressionContext>();
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) {
+ return GetRuleContext<ExpressionContext>(i);
+ }
+ public TernaryExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitTernaryExpression(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+ public partial class CompoundBitwiseLeftShiftExpressionContext : ExpressionContext {
+ [System.Diagnostics.DebuggerNonUserCode] public TargetContext target() {
+ return GetRuleContext<TargetContext>(0);
+ }
+ [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression() {
+ return GetRuleContext<ExpressionContext>(0);
+ }
+ public CompoundBitwiseLeftShiftExpressionContext(ExpressionContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitCompoundBitwiseLeftShiftExpression(this);
else return visitor.VisitChildren(this);
}
}
@@ -594,87 +1209,283 @@ public partial class CGrammarParser : Parser {
int _parentState = State;
ExpressionContext _localctx = new ExpressionContext(Context, _parentState);
ExpressionContext _prevctx = _localctx;
- int _startState = 6;
- EnterRecursionRule(_localctx, 6, RULE_expression, _p);
+ int _startState = 14;
+ EnterRecursionRule(_localctx, 14, RULE_expression, _p);
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
- State = 40;
+ State = 135;
ErrorHandler.Sync(this);
- switch (TokenStream.LA(1)) {
- case T__1:
+ switch ( Interpreter.AdaptivePredict(TokenStream,5,Context) ) {
+ case 1:
{
_localctx = new ParenthesizedExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 31;
+ State = 70;
Match(T__1);
- State = 32;
+ State = 71;
expression(0);
- State = 33;
+ State = 72;
Match(T__2);
}
break;
- case T__7:
+ case 2:
+ {
+ _localctx = new ConstantExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 74;
+ constant();
+ }
+ break;
+ case 3:
+ {
+ _localctx = new AssignmentExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 75;
+ target();
+ State = 76;
+ Match(T__9);
+ State = 77;
+ expression(0);
+ State = 78;
+ Match(T__6);
+ }
+ break;
+ case 4:
+ {
+ _localctx = new VariableExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 80;
+ Match(ID);
+ }
+ break;
+ case 5:
{
_localctx = new NotExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 35;
- Match(T__7);
- State = 36;
- expression(19);
+ State = 81;
+ Match(T__10);
+ State = 82;
+ expression(36);
}
break;
- case T__8:
+ case 6:
{
_localctx = new InvertExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 37;
- Match(T__8);
- State = 38;
- expression(18);
+ State = 83;
+ Match(T__11);
+ State = 84;
+ expression(35);
}
break;
- case INT:
+ case 7:
{
- _localctx = new ConstantExpressionContext(_localctx);
+ _localctx = new IncrementPrefixExpressionContext(_localctx);
Context = _localctx;
_prevctx = _localctx;
- State = 39;
- constant();
+ State = 85;
+ Match(T__12);
+ State = 86;
+ target();
+ }
+ break;
+ case 8:
+ {
+ _localctx = new DecrementPrefixExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 87;
+ Match(T__13);
+ State = 88;
+ target();
+ }
+ break;
+ case 9:
+ {
+ _localctx = new IncrementPostfixExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 89;
+ target();
+ State = 90;
+ Match(T__12);
+ }
+ break;
+ case 10:
+ {
+ _localctx = new DecrementPostfixExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 92;
+ target();
+ State = 93;
+ Match(T__13);
+ }
+ break;
+ case 11:
+ {
+ _localctx = new CompoundMultiplyExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 95;
+ target();
+ State = 96;
+ Match(T__32);
+ State = 97;
+ expression(12);
+ }
+ break;
+ case 12:
+ {
+ _localctx = new CompoundDivideExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 99;
+ target();
+ State = 100;
+ Match(T__33);
+ State = 101;
+ expression(11);
+ }
+ break;
+ case 13:
+ {
+ _localctx = new CompoundModulusExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 103;
+ target();
+ State = 104;
+ Match(T__34);
+ State = 105;
+ expression(10);
+ }
+ break;
+ case 14:
+ {
+ _localctx = new CompoundAddExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 107;
+ target();
+ State = 108;
+ Match(T__35);
+ State = 109;
+ expression(9);
+ }
+ break;
+ case 15:
+ {
+ _localctx = new CompoundSubtractExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 111;
+ target();
+ State = 112;
+ Match(T__36);
+ State = 113;
+ expression(8);
+ }
+ break;
+ case 16:
+ {
+ _localctx = new CompoundBitwiseAndExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 115;
+ target();
+ State = 116;
+ Match(T__37);
+ State = 117;
+ expression(7);
+ }
+ break;
+ case 17:
+ {
+ _localctx = new CompoundBitwiseOrExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 119;
+ target();
+ State = 120;
+ Match(T__38);
+ State = 121;
+ expression(6);
+ }
+ break;
+ case 18:
+ {
+ _localctx = new CompoundBitwiseXorExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 123;
+ target();
+ State = 124;
+ Match(T__39);
+ State = 125;
+ expression(5);
+ }
+ break;
+ case 19:
+ {
+ _localctx = new CompoundBitwiseLeftShiftExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 127;
+ target();
+ State = 128;
+ Match(T__40);
+ State = 129;
+ expression(4);
+ }
+ break;
+ case 20:
+ {
+ _localctx = new CompoundBitwiseRightShiftExpressionContext(_localctx);
+ Context = _localctx;
+ _prevctx = _localctx;
+ State = 131;
+ target();
+ State = 132;
+ Match(T__41);
+ State = 133;
+ expression(3);
}
break;
- default:
- throw new NoViableAltException(this);
}
Context.Stop = TokenStream.LT(-1);
- State = 92;
+ State = 202;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,3,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( ParseListeners!=null )
TriggerExitRuleEvent();
_prevctx = _localctx;
{
- State = 90;
+ State = 200;
ErrorHandler.Sync(this);
- switch ( Interpreter.AdaptivePredict(TokenStream,2,Context) ) {
+ switch ( Interpreter.AdaptivePredict(TokenStream,6,Context) ) {
case 1:
{
_localctx = new MultiplyExpressionContext(new ExpressionContext(_parentctx, _parentState));
((MultiplyExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 42;
- if (!(Precpred(Context, 17))) throw new FailedPredicateException(this, "Precpred(Context, 17)");
- State = 43;
- Match(T__9);
- State = 44;
- ((MultiplyExpressionContext)_localctx).right = expression(18);
+ State = 137;
+ if (!(Precpred(Context, 30))) throw new FailedPredicateException(this, "Precpred(Context, 30)");
+ State = 138;
+ Match(T__14);
+ State = 139;
+ ((MultiplyExpressionContext)_localctx).right = expression(31);
}
break;
case 2:
@@ -682,12 +1493,12 @@ public partial class CGrammarParser : Parser {
_localctx = new DivideExpressionContext(new ExpressionContext(_parentctx, _parentState));
((DivideExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 45;
- if (!(Precpred(Context, 16))) throw new FailedPredicateException(this, "Precpred(Context, 16)");
- State = 46;
- Match(T__10);
- State = 47;
- ((DivideExpressionContext)_localctx).right = expression(17);
+ State = 140;
+ if (!(Precpred(Context, 29))) throw new FailedPredicateException(this, "Precpred(Context, 29)");
+ State = 141;
+ Match(T__15);
+ State = 142;
+ ((DivideExpressionContext)_localctx).right = expression(30);
}
break;
case 3:
@@ -695,12 +1506,12 @@ public partial class CGrammarParser : Parser {
_localctx = new ModulusExpressionContext(new ExpressionContext(_parentctx, _parentState));
((ModulusExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 48;
- if (!(Precpred(Context, 15))) throw new FailedPredicateException(this, "Precpred(Context, 15)");
- State = 49;
- Match(T__11);
- State = 50;
- ((ModulusExpressionContext)_localctx).right = expression(16);
+ State = 143;
+ if (!(Precpred(Context, 28))) throw new FailedPredicateException(this, "Precpred(Context, 28)");
+ State = 144;
+ Match(T__16);
+ State = 145;
+ ((ModulusExpressionContext)_localctx).right = expression(29);
}
break;
case 4:
@@ -708,12 +1519,12 @@ public partial class CGrammarParser : Parser {
_localctx = new AddExpressionContext(new ExpressionContext(_parentctx, _parentState));
((AddExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 51;
- if (!(Precpred(Context, 14))) throw new FailedPredicateException(this, "Precpred(Context, 14)");
- State = 52;
- Match(T__12);
- State = 53;
- ((AddExpressionContext)_localctx).right = expression(15);
+ State = 146;
+ if (!(Precpred(Context, 27))) throw new FailedPredicateException(this, "Precpred(Context, 27)");
+ State = 147;
+ Match(T__17);
+ State = 148;
+ ((AddExpressionContext)_localctx).right = expression(28);
}
break;
case 5:
@@ -721,12 +1532,12 @@ public partial class CGrammarParser : Parser {
_localctx = new SubtractExpressionContext(new ExpressionContext(_parentctx, _parentState));
((SubtractExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 54;
- if (!(Precpred(Context, 13))) throw new FailedPredicateException(this, "Precpred(Context, 13)");
- State = 55;
- Match(T__13);
- State = 56;
- ((SubtractExpressionContext)_localctx).right = expression(14);
+ State = 149;
+ if (!(Precpred(Context, 26))) throw new FailedPredicateException(this, "Precpred(Context, 26)");
+ State = 150;
+ Match(T__18);
+ State = 151;
+ ((SubtractExpressionContext)_localctx).right = expression(27);
}
break;
case 6:
@@ -734,12 +1545,12 @@ public partial class CGrammarParser : Parser {
_localctx = new LessThanExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LessThanExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 57;
- if (!(Precpred(Context, 12))) throw new FailedPredicateException(this, "Precpred(Context, 12)");
- State = 58;
- Match(T__14);
- State = 59;
- ((LessThanExpressionContext)_localctx).right = expression(13);
+ State = 152;
+ if (!(Precpred(Context, 25))) throw new FailedPredicateException(this, "Precpred(Context, 25)");
+ State = 153;
+ Match(T__19);
+ State = 154;
+ ((LessThanExpressionContext)_localctx).right = expression(26);
}
break;
case 7:
@@ -747,12 +1558,12 @@ public partial class CGrammarParser : Parser {
_localctx = new GreaterThanExpressionContext(new ExpressionContext(_parentctx, _parentState));
((GreaterThanExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 60;
- if (!(Precpred(Context, 11))) throw new FailedPredicateException(this, "Precpred(Context, 11)");
- State = 61;
- Match(T__15);
- State = 62;
- ((GreaterThanExpressionContext)_localctx).right = expression(12);
+ State = 155;
+ if (!(Precpred(Context, 24))) throw new FailedPredicateException(this, "Precpred(Context, 24)");
+ State = 156;
+ Match(T__20);
+ State = 157;
+ ((GreaterThanExpressionContext)_localctx).right = expression(25);
}
break;
case 8:
@@ -760,12 +1571,12 @@ public partial class CGrammarParser : Parser {
_localctx = new LessThanOrEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LessThanOrEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 63;
- if (!(Precpred(Context, 10))) throw new FailedPredicateException(this, "Precpred(Context, 10)");
- State = 64;
- Match(T__16);
- State = 65;
- ((LessThanOrEqualExpressionContext)_localctx).right = expression(11);
+ State = 158;
+ if (!(Precpred(Context, 23))) throw new FailedPredicateException(this, "Precpred(Context, 23)");
+ State = 159;
+ Match(T__21);
+ State = 160;
+ ((LessThanOrEqualExpressionContext)_localctx).right = expression(24);
}
break;
case 9:
@@ -773,12 +1584,12 @@ public partial class CGrammarParser : Parser {
_localctx = new GreaterThanOrEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((GreaterThanOrEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 66;
- if (!(Precpred(Context, 9))) throw new FailedPredicateException(this, "Precpred(Context, 9)");
- State = 67;
- Match(T__17);
- State = 68;
- ((GreaterThanOrEqualExpressionContext)_localctx).right = expression(10);
+ State = 161;
+ if (!(Precpred(Context, 22))) throw new FailedPredicateException(this, "Precpred(Context, 22)");
+ State = 162;
+ Match(T__22);
+ State = 163;
+ ((GreaterThanOrEqualExpressionContext)_localctx).right = expression(23);
}
break;
case 10:
@@ -786,12 +1597,12 @@ public partial class CGrammarParser : Parser {
_localctx = new EqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((EqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 69;
- if (!(Precpred(Context, 8))) throw new FailedPredicateException(this, "Precpred(Context, 8)");
- State = 70;
- Match(T__18);
- State = 71;
- ((EqualExpressionContext)_localctx).right = expression(9);
+ State = 164;
+ if (!(Precpred(Context, 21))) throw new FailedPredicateException(this, "Precpred(Context, 21)");
+ State = 165;
+ Match(T__23);
+ State = 166;
+ ((EqualExpressionContext)_localctx).right = expression(22);
}
break;
case 11:
@@ -799,12 +1610,12 @@ public partial class CGrammarParser : Parser {
_localctx = new NotEqualExpressionContext(new ExpressionContext(_parentctx, _parentState));
((NotEqualExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 72;
- if (!(Precpred(Context, 7))) throw new FailedPredicateException(this, "Precpred(Context, 7)");
- State = 73;
- Match(T__19);
- State = 74;
- ((NotEqualExpressionContext)_localctx).right = expression(8);
+ State = 167;
+ if (!(Precpred(Context, 20))) throw new FailedPredicateException(this, "Precpred(Context, 20)");
+ State = 168;
+ Match(T__24);
+ State = 169;
+ ((NotEqualExpressionContext)_localctx).right = expression(21);
}
break;
case 12:
@@ -812,12 +1623,12 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseAndExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseAndExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 75;
- if (!(Precpred(Context, 6))) throw new FailedPredicateException(this, "Precpred(Context, 6)");
- State = 76;
- Match(T__20);
- State = 77;
- ((BitwiseAndExpressionContext)_localctx).right = expression(7);
+ State = 170;
+ if (!(Precpred(Context, 19))) throw new FailedPredicateException(this, "Precpred(Context, 19)");
+ State = 171;
+ Match(T__25);
+ State = 172;
+ ((BitwiseAndExpressionContext)_localctx).right = expression(20);
}
break;
case 13:
@@ -825,12 +1636,12 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseOrExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseOrExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 78;
- if (!(Precpred(Context, 5))) throw new FailedPredicateException(this, "Precpred(Context, 5)");
- State = 79;
- Match(T__21);
- State = 80;
- ((BitwiseOrExpressionContext)_localctx).right = expression(6);
+ State = 173;
+ if (!(Precpred(Context, 18))) throw new FailedPredicateException(this, "Precpred(Context, 18)");
+ State = 174;
+ Match(T__26);
+ State = 175;
+ ((BitwiseOrExpressionContext)_localctx).right = expression(19);
}
break;
case 14:
@@ -838,46 +1649,102 @@ public partial class CGrammarParser : Parser {
_localctx = new BitwiseXorExpressionContext(new ExpressionContext(_parentctx, _parentState));
((BitwiseXorExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 81;
- if (!(Precpred(Context, 4))) throw new FailedPredicateException(this, "Precpred(Context, 4)");
- State = 82;
- Match(T__22);
- State = 83;
- ((BitwiseXorExpressionContext)_localctx).right = expression(5);
+ State = 176;
+ if (!(Precpred(Context, 17))) throw new FailedPredicateException(this, "Precpred(Context, 17)");
+ State = 177;
+ Match(T__27);
+ State = 178;
+ ((BitwiseXorExpressionContext)_localctx).right = expression(18);
}
break;
case 15:
{
+ _localctx = new BitwiseLeftShiftExpressionContext(new ExpressionContext(_parentctx, _parentState));
+ ((BitwiseLeftShiftExpressionContext)_localctx).left = _prevctx;
+ PushNewRecursionContext(_localctx, _startState, RULE_expression);
+ State = 179;
+ if (!(Precpred(Context, 16))) throw new FailedPredicateException(this, "Precpred(Context, 16)");
+ State = 180;
+ Match(T__28);
+ State = 181;
+ ((BitwiseLeftShiftExpressionContext)_localctx).right = expression(17);
+ }
+ break;
+ case 16:
+ {
+ _localctx = new BitwiseRightShiftExpressionContext(new ExpressionContext(_parentctx, _parentState));
+ ((BitwiseRightShiftExpressionContext)_localctx).left = _prevctx;
+ PushNewRecursionContext(_localctx, _startState, RULE_expression);
+ State = 182;
+ if (!(Precpred(Context, 15))) throw new FailedPredicateException(this, "Precpred(Context, 15)");
+ State = 183;
+ Match(T__29);
+ State = 184;
+ ((BitwiseRightShiftExpressionContext)_localctx).right = expression(16);
+ }
+ break;
+ case 17:
+ {
_localctx = new LogicalAndExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LogicalAndExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 84;
- if (!(Precpred(Context, 3))) throw new FailedPredicateException(this, "Precpred(Context, 3)");
- State = 85;
- Match(T__23);
- State = 86;
- ((LogicalAndExpressionContext)_localctx).right = expression(4);
+ State = 185;
+ if (!(Precpred(Context, 14))) throw new FailedPredicateException(this, "Precpred(Context, 14)");
+ State = 186;
+ Match(T__30);
+ State = 187;
+ ((LogicalAndExpressionContext)_localctx).right = expression(15);
}
break;
- case 16:
+ case 18:
{
_localctx = new LogicalOrExpressionContext(new ExpressionContext(_parentctx, _parentState));
((LogicalOrExpressionContext)_localctx).left = _prevctx;
PushNewRecursionContext(_localctx, _startState, RULE_expression);
- State = 87;
+ State = 188;
+ if (!(Precpred(Context, 13))) throw new FailedPredicateException(this, "Precpred(Context, 13)");
+ State = 189;
+ Match(T__31);
+ State = 190;
+ ((LogicalOrExpressionContext)_localctx).right = expression(14);
+ }
+ break;
+ case 19:
+ {
+ _localctx = new CommaExpressionContext(new ExpressionContext(_parentctx, _parentState));
+ ((CommaExpressionContext)_localctx).left = _prevctx;
+ PushNewRecursionContext(_localctx, _startState, RULE_expression);
+ State = 191;
if (!(Precpred(Context, 2))) throw new FailedPredicateException(this, "Precpred(Context, 2)");
- State = 88;
- Match(T__24);
- State = 89;
- ((LogicalOrExpressionContext)_localctx).right = expression(3);
+ State = 192;
+ Match(T__42);
+ State = 193;
+ ((CommaExpressionContext)_localctx).right = expression(3);
+ }
+ break;
+ case 20:
+ {
+ _localctx = new TernaryExpressionContext(new ExpressionContext(_parentctx, _parentState));
+ ((TernaryExpressionContext)_localctx).cond = _prevctx;
+ PushNewRecursionContext(_localctx, _startState, RULE_expression);
+ State = 194;
+ if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
+ State = 195;
+ Match(T__43);
+ State = 196;
+ ((TernaryExpressionContext)_localctx).then = expression(0);
+ State = 197;
+ Match(T__44);
+ State = 198;
+ ((TernaryExpressionContext)_localctx).@else = expression(2);
}
break;
}
}
}
- State = 94;
+ State = 204;
ErrorHandler.Sync(this);
- _alt = Interpreter.AdaptivePredict(TokenStream,3,Context);
+ _alt = Interpreter.AdaptivePredict(TokenStream,7,Context);
}
}
}
@@ -918,12 +1785,12 @@ public partial class CGrammarParser : Parser {
[RuleVersion(0)]
public ConstantContext constant() {
ConstantContext _localctx = new ConstantContext(Context, State);
- EnterRule(_localctx, 8, RULE_constant);
+ EnterRule(_localctx, 16, RULE_constant);
try {
_localctx = new IntConstantContext(_localctx);
EnterOuterAlt(_localctx, 1);
{
- State = 95;
+ State = 205;
Match(INT);
}
}
@@ -938,65 +1805,154 @@ public partial class CGrammarParser : Parser {
return _localctx;
}
+ public partial class TargetContext : ParserRuleContext {
+ public TargetContext(ParserRuleContext parent, int invokingState)
+ : base(parent, invokingState)
+ {
+ }
+ public override int RuleIndex { get { return RULE_target; } }
+
+ public TargetContext() { }
+ public virtual void CopyFrom(TargetContext context) {
+ base.CopyFrom(context);
+ }
+ }
+ public partial class VariableTargetContext : TargetContext {
+ [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CGrammarParser.ID, 0); }
+ public VariableTargetContext(TargetContext context) { CopyFrom(context); }
+ [System.Diagnostics.DebuggerNonUserCode]
+ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor) {
+ ICGrammarVisitor<TResult> typedVisitor = visitor as ICGrammarVisitor<TResult>;
+ if (typedVisitor != null) return typedVisitor.VisitVariableTarget(this);
+ else return visitor.VisitChildren(this);
+ }
+ }
+
+ [RuleVersion(0)]
+ public TargetContext target() {
+ TargetContext _localctx = new TargetContext(Context, State);
+ EnterRule(_localctx, 18, RULE_target);
+ try {
+ _localctx = new VariableTargetContext(_localctx);
+ EnterOuterAlt(_localctx, 1);
+ {
+ State = 207;
+ Match(ID);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ ErrorHandler.ReportError(this, re);
+ ErrorHandler.Recover(this, re);
+ }
+ finally {
+ ExitRule();
+ }
+ return _localctx;
+ }
+
public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
- case 3: return expression_sempred((ExpressionContext)_localctx, predIndex);
+ case 7: return expression_sempred((ExpressionContext)_localctx, predIndex);
}
return true;
}
private bool expression_sempred(ExpressionContext _localctx, int predIndex) {
switch (predIndex) {
- case 0: return Precpred(Context, 17);
- case 1: return Precpred(Context, 16);
- case 2: return Precpred(Context, 15);
- case 3: return Precpred(Context, 14);
- case 4: return Precpred(Context, 13);
- case 5: return Precpred(Context, 12);
- case 6: return Precpred(Context, 11);
- case 7: return Precpred(Context, 10);
- case 8: return Precpred(Context, 9);
- case 9: return Precpred(Context, 8);
- case 10: return Precpred(Context, 7);
- case 11: return Precpred(Context, 6);
- case 12: return Precpred(Context, 5);
- case 13: return Precpred(Context, 4);
- case 14: return Precpred(Context, 3);
- case 15: return Precpred(Context, 2);
+ case 0: return Precpred(Context, 30);
+ case 1: return Precpred(Context, 29);
+ case 2: return Precpred(Context, 28);
+ case 3: return Precpred(Context, 27);
+ case 4: return Precpred(Context, 26);
+ case 5: return Precpred(Context, 25);
+ case 6: return Precpred(Context, 24);
+ case 7: return Precpred(Context, 23);
+ case 8: return Precpred(Context, 22);
+ case 9: return Precpred(Context, 21);
+ case 10: return Precpred(Context, 20);
+ case 11: return Precpred(Context, 19);
+ case 12: return Precpred(Context, 18);
+ case 13: return Precpred(Context, 17);
+ case 14: return Precpred(Context, 16);
+ case 15: return Precpred(Context, 15);
+ case 16: return Precpred(Context, 14);
+ case 17: return Precpred(Context, 13);
+ case 18: return Precpred(Context, 2);
+ case 19: return Precpred(Context, 1);
}
return true;
}
private static int[] _serializedATN = {
- 4,1,27,98,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,1,0,1,0,1,0,1,1,1,1,
- 1,1,1,1,1,1,1,1,5,1,20,8,1,10,1,12,1,23,9,1,1,1,1,1,1,2,1,2,1,2,1,2,1,
- 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,41,8,3,1,3,1,3,1,3,1,3,1,3,1,
- 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,
- 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,
- 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,5,3,91,8,3,10,3,12,3,94,9,3,1,4,1,4,1,4,
- 0,1,6,5,0,2,4,6,8,0,0,112,0,10,1,0,0,0,2,13,1,0,0,0,4,26,1,0,0,0,6,40,
- 1,0,0,0,8,95,1,0,0,0,10,11,3,2,1,0,11,12,5,0,0,1,12,1,1,0,0,0,13,14,5,
- 1,0,0,14,15,5,26,0,0,15,16,5,2,0,0,16,17,5,3,0,0,17,21,5,4,0,0,18,20,3,
- 4,2,0,19,18,1,0,0,0,20,23,1,0,0,0,21,19,1,0,0,0,21,22,1,0,0,0,22,24,1,
- 0,0,0,23,21,1,0,0,0,24,25,5,5,0,0,25,3,1,0,0,0,26,27,5,6,0,0,27,28,3,6,
- 3,0,28,29,5,7,0,0,29,5,1,0,0,0,30,31,6,3,-1,0,31,32,5,2,0,0,32,33,3,6,
- 3,0,33,34,5,3,0,0,34,41,1,0,0,0,35,36,5,8,0,0,36,41,3,6,3,19,37,38,5,9,
- 0,0,38,41,3,6,3,18,39,41,3,8,4,0,40,30,1,0,0,0,40,35,1,0,0,0,40,37,1,0,
- 0,0,40,39,1,0,0,0,41,92,1,0,0,0,42,43,10,17,0,0,43,44,5,10,0,0,44,91,3,
- 6,3,18,45,46,10,16,0,0,46,47,5,11,0,0,47,91,3,6,3,17,48,49,10,15,0,0,49,
- 50,5,12,0,0,50,91,3,6,3,16,51,52,10,14,0,0,52,53,5,13,0,0,53,91,3,6,3,
- 15,54,55,10,13,0,0,55,56,5,14,0,0,56,91,3,6,3,14,57,58,10,12,0,0,58,59,
- 5,15,0,0,59,91,3,6,3,13,60,61,10,11,0,0,61,62,5,16,0,0,62,91,3,6,3,12,
- 63,64,10,10,0,0,64,65,5,17,0,0,65,91,3,6,3,11,66,67,10,9,0,0,67,68,5,18,
- 0,0,68,91,3,6,3,10,69,70,10,8,0,0,70,71,5,19,0,0,71,91,3,6,3,9,72,73,10,
- 7,0,0,73,74,5,20,0,0,74,91,3,6,3,8,75,76,10,6,0,0,76,77,5,21,0,0,77,91,
- 3,6,3,7,78,79,10,5,0,0,79,80,5,22,0,0,80,91,3,6,3,6,81,82,10,4,0,0,82,
- 83,5,23,0,0,83,91,3,6,3,5,84,85,10,3,0,0,85,86,5,24,0,0,86,91,3,6,3,4,
- 87,88,10,2,0,0,88,89,5,25,0,0,89,91,3,6,3,3,90,42,1,0,0,0,90,45,1,0,0,
- 0,90,48,1,0,0,0,90,51,1,0,0,0,90,54,1,0,0,0,90,57,1,0,0,0,90,60,1,0,0,
- 0,90,63,1,0,0,0,90,66,1,0,0,0,90,69,1,0,0,0,90,72,1,0,0,0,90,75,1,0,0,
- 0,90,78,1,0,0,0,90,81,1,0,0,0,90,84,1,0,0,0,90,87,1,0,0,0,91,94,1,0,0,
- 0,92,90,1,0,0,0,92,93,1,0,0,0,93,7,1,0,0,0,94,92,1,0,0,0,95,96,5,27,0,
- 0,96,9,1,0,0,0,4,21,40,90,92
+ 4,1,49,210,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,
+ 7,7,2,8,7,8,2,9,7,9,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,3,2,32,
+ 8,2,1,3,1,3,5,3,36,8,3,10,3,12,3,39,9,3,1,3,1,3,1,4,1,4,3,4,45,8,4,1,5,
+ 1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,60,8,5,1,6,1,6,1,6,
+ 1,6,3,6,66,8,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
+ 1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,
+ 7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
+ 1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,
+ 7,1,7,3,7,136,8,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
+ 1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,
+ 7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
+ 1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,5,7,201,8,
+ 7,10,7,12,7,204,9,7,1,8,1,8,1,9,1,9,1,9,0,1,14,10,0,2,4,6,8,10,12,14,16,
+ 18,0,0,244,0,20,1,0,0,0,2,23,1,0,0,0,4,31,1,0,0,0,6,33,1,0,0,0,8,44,1,
+ 0,0,0,10,59,1,0,0,0,12,61,1,0,0,0,14,135,1,0,0,0,16,205,1,0,0,0,18,207,
+ 1,0,0,0,20,21,3,2,1,0,21,22,5,0,0,1,22,1,1,0,0,0,23,24,5,1,0,0,24,25,5,
+ 46,0,0,25,26,5,2,0,0,26,27,5,3,0,0,27,28,3,6,3,0,28,3,1,0,0,0,29,32,3,
+ 10,5,0,30,32,3,6,3,0,31,29,1,0,0,0,31,30,1,0,0,0,32,5,1,0,0,0,33,37,5,
+ 4,0,0,34,36,3,8,4,0,35,34,1,0,0,0,36,39,1,0,0,0,37,35,1,0,0,0,37,38,1,
+ 0,0,0,38,40,1,0,0,0,39,37,1,0,0,0,40,41,5,5,0,0,41,7,1,0,0,0,42,45,3,10,
+ 5,0,43,45,3,12,6,0,44,42,1,0,0,0,44,43,1,0,0,0,45,9,1,0,0,0,46,47,5,6,
+ 0,0,47,48,3,14,7,0,48,49,5,7,0,0,49,60,1,0,0,0,50,51,5,8,0,0,51,52,5,2,
+ 0,0,52,53,3,14,7,0,53,54,5,3,0,0,54,55,3,4,2,0,55,56,5,9,0,0,56,57,3,4,
+ 2,0,57,60,1,0,0,0,58,60,3,14,7,0,59,46,1,0,0,0,59,50,1,0,0,0,59,58,1,0,
+ 0,0,60,11,1,0,0,0,61,62,5,1,0,0,62,65,5,46,0,0,63,64,5,10,0,0,64,66,3,
+ 14,7,0,65,63,1,0,0,0,65,66,1,0,0,0,66,67,1,0,0,0,67,68,5,7,0,0,68,13,1,
+ 0,0,0,69,70,6,7,-1,0,70,71,5,2,0,0,71,72,3,14,7,0,72,73,5,3,0,0,73,136,
+ 1,0,0,0,74,136,3,16,8,0,75,76,3,18,9,0,76,77,5,10,0,0,77,78,3,14,7,0,78,
+ 79,5,7,0,0,79,136,1,0,0,0,80,136,5,46,0,0,81,82,5,11,0,0,82,136,3,14,7,
+ 36,83,84,5,12,0,0,84,136,3,14,7,35,85,86,5,13,0,0,86,136,3,18,9,0,87,88,
+ 5,14,0,0,88,136,3,18,9,0,89,90,3,18,9,0,90,91,5,13,0,0,91,136,1,0,0,0,
+ 92,93,3,18,9,0,93,94,5,14,0,0,94,136,1,0,0,0,95,96,3,18,9,0,96,97,5,33,
+ 0,0,97,98,3,14,7,12,98,136,1,0,0,0,99,100,3,18,9,0,100,101,5,34,0,0,101,
+ 102,3,14,7,11,102,136,1,0,0,0,103,104,3,18,9,0,104,105,5,35,0,0,105,106,
+ 3,14,7,10,106,136,1,0,0,0,107,108,3,18,9,0,108,109,5,36,0,0,109,110,3,
+ 14,7,9,110,136,1,0,0,0,111,112,3,18,9,0,112,113,5,37,0,0,113,114,3,14,
+ 7,8,114,136,1,0,0,0,115,116,3,18,9,0,116,117,5,38,0,0,117,118,3,14,7,7,
+ 118,136,1,0,0,0,119,120,3,18,9,0,120,121,5,39,0,0,121,122,3,14,7,6,122,
+ 136,1,0,0,0,123,124,3,18,9,0,124,125,5,40,0,0,125,126,3,14,7,5,126,136,
+ 1,0,0,0,127,128,3,18,9,0,128,129,5,41,0,0,129,130,3,14,7,4,130,136,1,0,
+ 0,0,131,132,3,18,9,0,132,133,5,42,0,0,133,134,3,14,7,3,134,136,1,0,0,0,
+ 135,69,1,0,0,0,135,74,1,0,0,0,135,75,1,0,0,0,135,80,1,0,0,0,135,81,1,0,
+ 0,0,135,83,1,0,0,0,135,85,1,0,0,0,135,87,1,0,0,0,135,89,1,0,0,0,135,92,
+ 1,0,0,0,135,95,1,0,0,0,135,99,1,0,0,0,135,103,1,0,0,0,135,107,1,0,0,0,
+ 135,111,1,0,0,0,135,115,1,0,0,0,135,119,1,0,0,0,135,123,1,0,0,0,135,127,
+ 1,0,0,0,135,131,1,0,0,0,136,202,1,0,0,0,137,138,10,30,0,0,138,139,5,15,
+ 0,0,139,201,3,14,7,31,140,141,10,29,0,0,141,142,5,16,0,0,142,201,3,14,
+ 7,30,143,144,10,28,0,0,144,145,5,17,0,0,145,201,3,14,7,29,146,147,10,27,
+ 0,0,147,148,5,18,0,0,148,201,3,14,7,28,149,150,10,26,0,0,150,151,5,19,
+ 0,0,151,201,3,14,7,27,152,153,10,25,0,0,153,154,5,20,0,0,154,201,3,14,
+ 7,26,155,156,10,24,0,0,156,157,5,21,0,0,157,201,3,14,7,25,158,159,10,23,
+ 0,0,159,160,5,22,0,0,160,201,3,14,7,24,161,162,10,22,0,0,162,163,5,23,
+ 0,0,163,201,3,14,7,23,164,165,10,21,0,0,165,166,5,24,0,0,166,201,3,14,
+ 7,22,167,168,10,20,0,0,168,169,5,25,0,0,169,201,3,14,7,21,170,171,10,19,
+ 0,0,171,172,5,26,0,0,172,201,3,14,7,20,173,174,10,18,0,0,174,175,5,27,
+ 0,0,175,201,3,14,7,19,176,177,10,17,0,0,177,178,5,28,0,0,178,201,3,14,
+ 7,18,179,180,10,16,0,0,180,181,5,29,0,0,181,201,3,14,7,17,182,183,10,15,
+ 0,0,183,184,5,30,0,0,184,201,3,14,7,16,185,186,10,14,0,0,186,187,5,31,
+ 0,0,187,201,3,14,7,15,188,189,10,13,0,0,189,190,5,32,0,0,190,201,3,14,
+ 7,14,191,192,10,2,0,0,192,193,5,43,0,0,193,201,3,14,7,3,194,195,10,1,0,
+ 0,195,196,5,44,0,0,196,197,3,14,7,0,197,198,5,45,0,0,198,199,3,14,7,2,
+ 199,201,1,0,0,0,200,137,1,0,0,0,200,140,1,0,0,0,200,143,1,0,0,0,200,146,
+ 1,0,0,0,200,149,1,0,0,0,200,152,1,0,0,0,200,155,1,0,0,0,200,158,1,0,0,
+ 0,200,161,1,0,0,0,200,164,1,0,0,0,200,167,1,0,0,0,200,170,1,0,0,0,200,
+ 173,1,0,0,0,200,176,1,0,0,0,200,179,1,0,0,0,200,182,1,0,0,0,200,185,1,
+ 0,0,0,200,188,1,0,0,0,200,191,1,0,0,0,200,194,1,0,0,0,201,204,1,0,0,0,
+ 202,200,1,0,0,0,202,203,1,0,0,0,203,15,1,0,0,0,204,202,1,0,0,0,205,206,
+ 5,47,0,0,206,17,1,0,0,0,207,208,5,46,0,0,208,19,1,0,0,0,8,31,37,44,59,
+ 65,135,200,202
};
public static readonly ATN _ATN =
diff --git a/Compiler/gen/CGrammarVisitor.cs b/Compiler/gen/CGrammarVisitor.cs
index 1f9691a..50cb551 100644
--- a/Compiler/gen/CGrammarVisitor.cs
+++ b/Compiler/gen/CGrammarVisitor.cs
@@ -44,6 +44,24 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitFunction([NotNull] CGrammarParser.FunctionContext context);
/// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.body"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitBody([NotNull] CGrammarParser.BodyContext context);
+ /// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.block"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitBlock([NotNull] CGrammarParser.BlockContext context);
+ /// <summary>
+ /// Visit a parse tree produced by <see cref="CGrammarParser.block_item"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitBlock_item([NotNull] CGrammarParser.Block_itemContext context);
+ /// <summary>
/// Visit a parse tree produced by the <c>returnStatement</c>
/// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// </summary>
@@ -51,26 +69,33 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitReturnStatement([NotNull] CGrammarParser.ReturnStatementContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>bitwiseXorExpression</c>
- /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// Visit a parse tree produced by the <c>ifStatement</c>
+ /// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitBitwiseXorExpression([NotNull] CGrammarParser.BitwiseXorExpressionContext context);
+ Result VisitIfStatement([NotNull] CGrammarParser.IfStatementContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>constantExpression</c>
- /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// Visit a parse tree produced by the <c>expressionStatement</c>
+ /// labeled alternative in <see cref="CGrammarParser.statement"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitConstantExpression([NotNull] CGrammarParser.ConstantExpressionContext context);
+ Result VisitExpressionStatement([NotNull] CGrammarParser.ExpressionStatementContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>lessThanOrEqualExpression</c>
+ /// Visit a parse tree produced by the <c>variableDeclaration</c>
+ /// labeled alternative in <see cref="CGrammarParser.declaration"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitVariableDeclaration([NotNull] CGrammarParser.VariableDeclarationContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundSubtractExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitLessThanOrEqualExpression([NotNull] CGrammarParser.LessThanOrEqualExpressionContext context);
+ Result VisitCompoundSubtractExpression([NotNull] CGrammarParser.CompoundSubtractExpressionContext context);
/// <summary>
/// Visit a parse tree produced by the <c>modulusExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -86,12 +111,12 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitNotExpression([NotNull] CGrammarParser.NotExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>notEqualExpression</c>
+ /// Visit a parse tree produced by the <c>decrementPrefixExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitNotEqualExpression([NotNull] CGrammarParser.NotEqualExpressionContext context);
+ Result VisitDecrementPrefixExpression([NotNull] CGrammarParser.DecrementPrefixExpressionContext context);
/// <summary>
/// Visit a parse tree produced by the <c>multiplyExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -107,33 +132,33 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitGreaterThanExpression([NotNull] CGrammarParser.GreaterThanExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>logicalOrExpression</c>
+ /// Visit a parse tree produced by the <c>bitwiseLeftShiftExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitLogicalOrExpression([NotNull] CGrammarParser.LogicalOrExpressionContext context);
+ Result VisitBitwiseLeftShiftExpression([NotNull] CGrammarParser.BitwiseLeftShiftExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>greaterThanOrEqualExpression</c>
+ /// Visit a parse tree produced by the <c>bitwiseRightShiftExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitGreaterThanOrEqualExpression([NotNull] CGrammarParser.GreaterThanOrEqualExpressionContext context);
+ Result VisitBitwiseRightShiftExpression([NotNull] CGrammarParser.BitwiseRightShiftExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>divideExpression</c>
+ /// Visit a parse tree produced by the <c>variableExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitDivideExpression([NotNull] CGrammarParser.DivideExpressionContext context);
+ Result VisitVariableExpression([NotNull] CGrammarParser.VariableExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>bitwiseOrExpression</c>
+ /// Visit a parse tree produced by the <c>compoundDivideExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitBitwiseOrExpression([NotNull] CGrammarParser.BitwiseOrExpressionContext context);
+ Result VisitCompoundDivideExpression([NotNull] CGrammarParser.CompoundDivideExpressionContext context);
/// <summary>
/// Visit a parse tree produced by the <c>parenthesizedExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -142,19 +167,26 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitParenthesizedExpression([NotNull] CGrammarParser.ParenthesizedExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>addExpression</c>
+ /// Visit a parse tree produced by the <c>compoundAddExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitAddExpression([NotNull] CGrammarParser.AddExpressionContext context);
+ Result VisitCompoundAddExpression([NotNull] CGrammarParser.CompoundAddExpressionContext context);
/// <summary>
- /// Visit a parse tree produced by the <c>subtractExpression</c>
+ /// Visit a parse tree produced by the <c>compoundMultiplyExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
- Result VisitSubtractExpression([NotNull] CGrammarParser.SubtractExpressionContext context);
+ Result VisitCompoundMultiplyExpression([NotNull] CGrammarParser.CompoundMultiplyExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseXorExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundBitwiseXorExpression([NotNull] CGrammarParser.CompoundBitwiseXorExpressionContext context);
/// <summary>
/// Visit a parse tree produced by the <c>bitwiseAndExpression</c>
/// labeled alternative in <see cref="CGrammarParser.expression"/>.
@@ -191,10 +223,164 @@ public interface ICGrammarVisitor<Result> : IParseTreeVisitor<Result> {
/// <return>The visitor result.</return>
Result VisitEqualExpression([NotNull] CGrammarParser.EqualExpressionContext context);
/// <summary>
+ /// Visit a parse tree produced by the <c>bitwiseXorExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitBitwiseXorExpression([NotNull] CGrammarParser.BitwiseXorExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>constantExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitConstantExpression([NotNull] CGrammarParser.ConstantExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundModulusExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundModulusExpression([NotNull] CGrammarParser.CompoundModulusExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>lessThanOrEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitLessThanOrEqualExpression([NotNull] CGrammarParser.LessThanOrEqualExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>incrementPostfixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitIncrementPostfixExpression([NotNull] CGrammarParser.IncrementPostfixExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseRightShiftExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundBitwiseRightShiftExpression([NotNull] CGrammarParser.CompoundBitwiseRightShiftExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>assignmentExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitAssignmentExpression([NotNull] CGrammarParser.AssignmentExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>notEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitNotEqualExpression([NotNull] CGrammarParser.NotEqualExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseAndExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundBitwiseAndExpression([NotNull] CGrammarParser.CompoundBitwiseAndExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>logicalOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitLogicalOrExpression([NotNull] CGrammarParser.LogicalOrExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>commaExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCommaExpression([NotNull] CGrammarParser.CommaExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>incrementPrefixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitIncrementPrefixExpression([NotNull] CGrammarParser.IncrementPrefixExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>greaterThanOrEqualExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitGreaterThanOrEqualExpression([NotNull] CGrammarParser.GreaterThanOrEqualExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>divideExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitDivideExpression([NotNull] CGrammarParser.DivideExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>bitwiseOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitBitwiseOrExpression([NotNull] CGrammarParser.BitwiseOrExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>addExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitAddExpression([NotNull] CGrammarParser.AddExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>subtractExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitSubtractExpression([NotNull] CGrammarParser.SubtractExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseOrExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundBitwiseOrExpression([NotNull] CGrammarParser.CompoundBitwiseOrExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>decrementPostfixExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitDecrementPostfixExpression([NotNull] CGrammarParser.DecrementPostfixExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>ternaryExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitTernaryExpression([NotNull] CGrammarParser.TernaryExpressionContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>compoundBitwiseLeftShiftExpression</c>
+ /// labeled alternative in <see cref="CGrammarParser.expression"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitCompoundBitwiseLeftShiftExpression([NotNull] CGrammarParser.CompoundBitwiseLeftShiftExpressionContext context);
+ /// <summary>
/// Visit a parse tree produced by the <c>intConstant</c>
/// labeled alternative in <see cref="CGrammarParser.constant"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitIntConstant([NotNull] CGrammarParser.IntConstantContext context);
+ /// <summary>
+ /// Visit a parse tree produced by the <c>variableTarget</c>
+ /// labeled alternative in <see cref="CGrammarParser.target"/>.
+ /// </summary>
+ /// <param name="context">The parse tree.</param>
+ /// <return>The visitor result.</return>
+ Result VisitVariableTarget([NotNull] CGrammarParser.VariableTargetContext context);
}