Commits

Kareem Callender committed b4d2ecc Draft

Removed some symbols from the lexer.
Added templates, for formatting data section output.
With templates, added string printing (null-terminated and fixed-length).
Added Table class, for loading table files to be used for string printing.
Default table is ASCII.
Coopted data length parameter in save format for template usage. Old usage
should be compatible.
Added new methods for grabbing 32 and 64 bit words from the file.
Removed unused error messages.

Comments (0)

Files changed (27)

gbread/Base/Assembler.cs

         private CodeGenerator codeGen = new CodeGenerator();
         private Dictionary<string, ITree> macroDict = new Dictionary<string, ITree>();
         private Stack<List<long>> macroArgStack = new Stack<List<long>>();
+        private CompError currentError = new CompError();
 
         private const string ExpressionToken = "EXPRESSION";
         private const string HLRefToken = "RR_REF_HL";
             symFillTable.Clear();
             macroDict.Clear();
             macroArgStack.Clear();
+            currentError = new CompError();
             GlobalScopeName = "_";
             LocalScopeName = "_";
             foreach (FunctionLabel kvp in lc.FuncList)
             Initialize();
 
             var syntaxTree = new CommonTree();
-            if (!CreateAST(input, out syntaxTree, ref error))
+            if (!CreateAST(input, out syntaxTree))
             {
+                error = currentError;
                 return new byte[1];
             }
 
-            if (!(EvaluateAST(syntaxTree, baseOffset, ref error)
-                && EvaluateSymbols(baseOffset, ref error)))
+            if (!(EvaluateAST(syntaxTree, baseOffset)
+                && EvaluateSymbols(baseOffset)))
             {
+                error = currentError;
                 return new byte[1];
             }
             success = true;
             return codeGen.StreamToArray();
         }
 
-        private bool CreateAST(string input, out CommonTree syntaxTree, ref CompError error)
+        private bool CreateAST(string input, out CommonTree syntaxTree)
         {
             var css = new CaseInsensitiveStringStream(input);
             var gblex = new GBXLexer(css);
             parseErrors.AddRange(gbparse.GetErrors());
             if (parseErrors.Count != 0)
             {
-                MakeErrorMessage(gbparse.GetErrors()[0], ref error);
+                MakeErrorMessage(parseErrors[0]);
                 return false;
             }
             return true;
         }
 
-        // TODO: Allow for building from multiple sources(i.e. "include").
+        // TODO: Allow for building from multiple sources("include").
         // TODO: Add "section"
-        private bool EvaluateAST(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateAST(ITree eval, int baseOffset)
         {
             for (int i = 0; i < eval.ChildCount; i++)
             {
                 {
                     case AssignmentToken:
                         {
-                            if (!EvaluateAssignment(eval.GetChild(i).GetChild(0), baseOffset, ref error))
+                            if (!EvaluateAssignment(eval.GetChild(i).GetChild(0), baseOffset))
                             {
                                 return false;
                             }
 
                     case MacroDefToken:
                         {
-                            if (!EvaluateMacroDef(eval.GetChild(i).GetChild(0), ref error))
+                            if (!EvaluateMacroDef(eval.GetChild(i).GetChild(0)))
                             {
                                 return false;
                             }
 
                     case StatementToken:
                         {
-                            if (!EvaluateStatement(eval.GetChild(i).GetChild(0), baseOffset, ref error))
+                            if (!EvaluateStatement(eval.GetChild(i).GetChild(0), baseOffset))
                             {
                                 return false;
                             }
             return true;
         }
 
-        private bool EvaluateSymbols(int baseOffset, ref CompError error)
+        private bool EvaluateSymbols(int baseOffset)
         {
             foreach (SymEntry se in symFillTable)
             {
                         long diff = memLoc - (se.instructionPosition + 2);
                         if (diff < -128 || diff > 127)
                         {
-                            MakeErrorMessage(se, ErrorMessage.Build_JROutOfRange, ref error);
+                            MakeErrorMessage(se, ErrorMessage.Build_JROutOfRange);
                             return false;
                         }
                         codeGen.EmitByte(diff);
                 }
                 else
                 {
-                    MakeErrorMessage(se, ErrorMessage.Build_UnknownLabel, ref error);
+                    MakeErrorMessage(se, ErrorMessage.Build_UnknownLabel);
                     return false;
                 }
             }
             return true;
         }
 
-        private bool EvaluateAssignment(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateAssignment(ITree eval, int baseOffset)
         {
             var varName = GetGlobalScopedID(eval.Text);
             if (variableDict.ContainsKey(varName))
             {
-                MakeErrorMessage(eval, ErrorMessage.Label_VariableAlreadyDefined, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Label_VariableAlreadyDefined);
                 return false;
             }
             var result = 0L;
-            if (!EvaluateExpression(eval.GetChild(0), out result, ref error))
+            if (!EvaluateExpression(eval.GetChild(0), out result))
             {
                 return false;
             }
             return true;
         }
 
-        private bool EvaluateMacroDef(ITree eval, ref CompError error)
+        private bool EvaluateMacroDef(ITree eval)
         {
             var macroName = GetGlobalScopedID(eval.Text);
             if (macroDict.ContainsKey(macroName))
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_MacroAlreadyDefined, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_MacroAlreadyDefined);
                 return false;
             }
             macroDict.Add(macroName, eval);
             return true;
         }
 
-        private bool EvaluateStatement(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateStatement(ITree eval, int baseOffset)
         {
             var labelDeclTree = eval.GetChild(0);
             var statementTree = eval.GetChild(1);
             for (int i = 0; i < labelDeclTree.ChildCount; i++)
             {
-                if (!EvaluateLabelDecl(labelDeclTree.GetChild(i), baseOffset, ref error))
+                if (!EvaluateLabelDecl(labelDeclTree.GetChild(i), baseOffset))
                 {
                     return false;
                 }
             {
                 case InstructionToken:
                     {
-                        return EvaluateInstruction(statementTree.GetChild(0), baseOffset, ref error);
+                        return EvaluateInstruction(statementTree.GetChild(0), baseOffset);
                     }
                 case PseudoInstToken:
                     {
-                        return EvaluatePseudoInst(statementTree.GetChild(0), baseOffset, ref error);
+                        return EvaluatePseudoInst(statementTree.GetChild(0), baseOffset);
                     }
                 default:
                     {
-                        MakeErrorMessage(eval, ErrorMessage.Build_UnknownError, ref error);
+                        MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
                         return false;
                     }
             }
         }
 
-        private bool EvaluateLabelDecl(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateLabelDecl(ITree eval, int baseOffset)
         {
             var labelName = eval.GetChild(0).Text;
             switch (eval.Text)
                         labelName = GetGlobalScopedID(labelName);
                         if (callDict.ContainsKey(labelName))
                         {
-                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined, ref error);
+                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined);
                             return false;
                         }
                         callDict.Add(exportScopedName, codeGen.Position + baseOffset);
                         labelName = GetGlobalScopedID(labelName);
                         if (callDict.ContainsKey(labelName))
                         {
-                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined, ref error);
+                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined);
                             return false;
                         }
                         callDict.Add(labelName, codeGen.Position + baseOffset);
                         labelName = GetLocalScopedID(labelName);
                         if (callDict.ContainsKey(labelName))
                         {
-                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined, ref error);
+                            MakeErrorMessage(eval.GetChild(0), ErrorMessage.Label_LabelAlreadyDefined);
                             return false;
                         }
                         callDict.Add(labelName, codeGen.Position + baseOffset);
 
                 default:
                     {
-                        MakeErrorMessage(eval, ErrorMessage.Build_UnknownError, ref error);
+                        MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
                         return false;
                     }
             }
             return true;
         }
 
-        private bool EvaluateInstruction(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateInstruction(ITree eval, int baseOffset)
         {
             switch (eval.Text)
             {
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitAdcN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitAdcN, arg))
                             {
                                 return false;
                             }
                             var arg = eval.GetChild(0);
                             if (arg.Text == ExpressionToken)
                             {
-                                if (!EvalArithArgFunc(codeGen.EmitAddN, arg, ref error))
+                                if (!EvalArithArgFunc(codeGen.EmitAddN, arg))
                                 {
                                     return false;
                                 }
                             {
                                 if (arg2.Text == ExpressionToken)
                                 {
-                                    if (!EvalArithArgFunc(codeGen.EmitAddN, arg2, ref error))
+                                    if (!EvalArithArgFunc(codeGen.EmitAddN, arg2))
                                     {
                                         return false;
                                     }
                             }
                             else
                             {
-                                if (!EvalArithArgFunc(codeGen.EmitAddSPN, arg2, ref error))
+                                if (!EvalArithArgFunc(codeGen.EmitAddSPN, arg2))
                                 {
                                     return false;
                                 }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitAndN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitAndN, arg))
                             {
                                 return false;
                             }
                     {
                         var arg = eval.GetChild(0);
                         var arg2 = eval.GetChild(1).Text;
-                        if (!EvalBitFunc(codeGen.EmitBitXR, arg, arg2, ref error))
+                        if (!EvalBitFunc(codeGen.EmitBitXR, arg, arg2))
                         {
                             return false;
                         }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitCpN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitCpN, arg))
                             {
                                 return false;
                             }
 
                             default:
                                 {
-                                    MakeErrorMessage(eval.GetChild(0), ErrorMessage.UNKNOWN_ARGUMENT, ref error);
+                                    MakeErrorMessage(eval.GetChild(0), ErrorMessage.Build_UnknownArgument);
                                     return false;
                                 }
                         }
 
                             default:
                                 {
-                                    MakeErrorMessage(eval.GetChild(0), ErrorMessage.UNKNOWN_ARGUMENT, ref error);
+                                    MakeErrorMessage(eval.GetChild(0), ErrorMessage.Build_UnknownArgument);
                                     return false;
                                 }
                         }
                             diff = memLoc - (codeGen.Position + 2);
                             if (diff < -128 || diff > 127)
                             {
-                                MakeErrorMessage(arg, ErrorMessage.Build_JROutOfRange, ref error);
+                                MakeErrorMessage(arg, ErrorMessage.Build_JROutOfRange);
                                 return false;
                             }
                         }
 
                 case "ldhl":
                     {
-                        if (!EvalArithArgFunc(codeGen.EmitLdHLSP, eval.GetChild(1), ref error))
+                        if (!EvalArithArgFunc(codeGen.EmitLdHLSP, eval.GetChild(1)))
                         {
                             return false;
                         }
                     {
                         if (eval.GetChild(0).Text == MemRefToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitLdioNA, eval.GetChild(0).GetChild(0), ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitLdioNA, eval.GetChild(0).GetChild(0)))
                             {
                                 return false;
                             }
                         }
                         else
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitLdioAN, eval.GetChild(1).GetChild(0), ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitLdioAN, eval.GetChild(1).GetChild(0)))
                             {
                                 return false;
                             }
                                     if (arg2.Text == ExpressionToken)
                                     {
                                         var result = 0L;
-                                        if (!EvaluateExpression(arg2.GetChild(0), out result, ref error))
+                                        if (!EvaluateExpression(arg2.GetChild(0), out result))
                                         {
                                             return false;
                                         }
                                     else if (arg2.Text == MemRefToken)
                                     {
                                         var result = 0L;
-                                        if (!EvaluateExpression(arg2.GetChild(0), out result, ref error))
+                                        if (!EvaluateExpression(arg2.GetChild(0), out result))
                                         {
                                             return false;
                                         }
                                     if (arg2.Text == ExpressionToken)
                                     {
                                         var result = 0L;
-                                        if (!EvaluateExpression(arg2.GetChild(0), out result, ref error))
+                                        if (!EvaluateExpression(arg2.GetChild(0), out result))
                                         {
                                             return false;
                                         }
                             case "hl":
                                 {
                                     var result = 0L;
-                                    if (!EvaluateExpression(arg2.GetChild(0), out result, ref error))
+                                    if (!EvaluateExpression(arg2.GetChild(0), out result))
                                     {
                                         return false;
                                     }
                                     if (arg2.Text == ExpressionToken)
                                     {
                                         var result = 0L;
-                                        if (!EvaluateExpression(arg2.GetChild(0), out result, ref error))
+                                        if (!EvaluateExpression(arg2.GetChild(0), out result))
                                         {
                                             return false;
                                         }
                             case "MEM_REF":
                                 {
                                     var result = 0L;
-                                    if (!EvaluateExpression(arg1.GetChild(0), out result, ref error))
+                                    if (!EvaluateExpression(arg1.GetChild(0), out result))
                                     {
                                         return false;
                                     }
                                     if (arg2.Text == ExpressionToken)
                                     {
                                         var result = 0L;
-                                        if (!(EvaluateExpression(arg2.GetChild(0), out result, ref error)))
+                                        if (!(EvaluateExpression(arg2.GetChild(0), out result)))
                                         {
                                             return false;
                                         }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitOrN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitOrN, arg))
                             {
                                 return false;
                             }
                     {
                         var arg = eval.GetChild(0);
                         var arg2 = eval.GetChild(1).Text;
-                        if (!EvalBitFunc(codeGen.EmitResXR, arg, arg2, ref error))
+                        if (!EvalBitFunc(codeGen.EmitResXR, arg, arg2))
                         {
                             return false;
                         }
 
                 case "rst":
                     {
-                        if (!EvalArithArgFunc(codeGen.EmitRst, eval.GetChild(0), ref error))
+                        if (!EvalArithArgFunc(codeGen.EmitRst, eval.GetChild(0)))
                         {
                             return false;
                         }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitSbcN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitSbcN, arg))
                             {
                                 return false;
                             }
                     {
                         var arg = eval.GetChild(0);
                         var arg2 = eval.GetChild(1).Text;
-                        if (!EvalBitFunc(codeGen.EmitSetXR, arg, arg2, ref error))
+                        if (!EvalBitFunc(codeGen.EmitSetXR, arg, arg2))
                         {
                             return false;
                         }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitSubN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitSubN, arg))
                             {
                                 return false;
                             }
                         var arg = eval.ChildCount == 1 ? eval.GetChild(0) : eval.GetChild(1);
                         if (arg.Text == ExpressionToken)
                         {
-                            if (!EvalArithArgFunc(codeGen.EmitXorN, arg, ref error))
+                            if (!EvalArithArgFunc(codeGen.EmitXorN, arg))
                             {
                                 return false;
                             }
             return true;
         }
 
-        private bool EvaluatePseudoInst(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluatePseudoInst(ITree eval, int baseOffset)
         {
             switch (eval.Text)
             {
                 case DataDefToken:
                     {
-                        return EvaluateDataDef(eval.GetChild(0), baseOffset, ref error);
+                        return EvaluateDataDef(eval.GetChild(0), baseOffset);
                     }
                 case MacroCallToken:
                     {
-                        return EvaluateMacroCall(eval.GetChild(0), baseOffset, ref error);
+                        return EvaluateMacroCall(eval.GetChild(0), baseOffset);
                     }
                 case IncludeToken:
                     {
-                        return EvaluateInclude(eval.GetChild(0), baseOffset, ref error);
+                        return EvaluateInclude(eval.GetChild(0), baseOffset);
                     }
                 default:
-                    return false;
+                    {
+                        MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
+                        return false;
+                    }
             }
         }
 
-        private bool EvaluateDataDef(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateDataDef(ITree eval, int baseOffset)
         {
             CodeGenerator.DataFuncDelegate dataFunc;
             switch (eval.Text)
                 {
                     var arg = eval.GetChild(i).GetChild(0);
                     var result = 0L;
-                    if (!EvaluateExpression(arg, out result, ref error))
+                    if (!EvaluateExpression(arg, out result))
                     {
                         return false;
                     }
             return true;
         }
 
-        private bool EvaluateMacroCall(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateMacroCall(ITree eval, int baseOffset)
         {
             var macroName = GetGlobalScopedID(eval.Text);
             if (!macroDict.ContainsKey(macroName))
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_MacroDoesNotExist, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_MacroDoesNotExist);
                 return false;
             }
             else
                 var result = 0L;
                 for (int i = 0; i < eval.ChildCount; i++)
                 {
-                    if (!EvaluateExpression(eval.GetChild(i).GetChild(0), out result, ref error))
+                    if (!EvaluateExpression(eval.GetChild(i).GetChild(0), out result))
                     {
                         return false;
                     }
                 macroArgStack.Push(macArgList);
                 var curScope = GetGlobalScope();
                 SetGlobalScope(eval.Text);
-                if (!EvaluateAST(macroDict[macroName], baseOffset, ref error))
+                if (!EvaluateAST(macroDict[macroName], baseOffset))
                 {
                     return false;
                 }
             }
         }
 
-        private bool EvaluateInclude(ITree eval, int baseOffset, ref CompError error)
+        private bool EvaluateInclude(ITree eval, int baseOffset)
         {
             // TODO: Write this function.
             // Search path for includes:
             // -Directory of binary
             // -Directory of program
+            MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
             return false;
         }
 
-        private bool EvaluateExpression(ITree eval, out long result, ref CompError error)
+        private bool EvaluateExpression(ITree eval, out long result)
         {
             result = 0;
             var res1 = 0L;
             var res3 = 0L;
             if (eval == null)
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
                 return false;
             }
             switch (eval.Text)
             {
                 case LiteralToken:
-                    return EvaluateLiteral(eval.GetChild(0), out result, ref error);
+                    return EvaluateLiteral(eval.GetChild(0), out result);
                 case VarToken:
-                    return EvaluateVar(eval.GetChild(0), out result, ref error);
+                    return EvaluateVar(eval.GetChild(0), out result);
                 case MacroArgToken:
-                    return EvaluateMacroArg(eval.GetChild(0), out result, ref error);
+                    return EvaluateMacroArg(eval.GetChild(0), out result);
                 default:
                     {
                         switch (eval.ChildCount)
                         {
                             case 1:
                                 {
-                                    if (!EvaluateExpression(eval.GetChild(0), out res1, ref error))
+                                    if (!EvaluateExpression(eval.GetChild(0), out res1))
                                     {
                                         return false;
                                     }
                                             return true;
                                         default:
                                             {
-                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                                                 return false;
                                             }
                                     }
                                 }
                             case 2:
                                 {
-                                    if (!(EvaluateExpression(eval.GetChild(0), out res1, ref error)
-                                        && EvaluateExpression(eval.GetChild(1), out res2, ref error)))
+                                    if (!(EvaluateExpression(eval.GetChild(0), out res1)
+                                        && EvaluateExpression(eval.GetChild(1), out res2)))
                                     {
                                         return false;
                                     }
                                             return true;
                                         default:
                                             {
-                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                                                 return false;
                                             }
                                     }
                                 }
                             case 3:
                                 {
-                                    if (!(EvaluateExpression(eval.GetChild(0), out res1, ref error)
-                                        && EvaluateExpression(eval.GetChild(1), out res2, ref error)
-                                        && EvaluateExpression(eval.GetChild(2), out res3, ref error)))
+                                    if (!(EvaluateExpression(eval.GetChild(0), out res1)
+                                        && EvaluateExpression(eval.GetChild(1), out res2)
+                                        && EvaluateExpression(eval.GetChild(2), out res3)))
                                     {
                                         return false;
                                     }
                                             return true;
                                         default:
                                             {
-                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                                                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                                                 return false;
                                             }
                                     }
                                 }
                             default:
                                 {
-                                    MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                                    MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                                     return false;
                                 }
                         }
             }
         }
 
-        private bool EvaluateMacroArg(ITree eval, out long result, ref CompError error)
+        private bool EvaluateMacroArg(ITree eval, out long result)
         {
             result = 0;
             int mIndex = 0;
             if (eval == null)
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
                 return false;
             }
             else if (macroArgStack.Count == 0)
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_MacroArgUsedOutsideOfDef, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_MacroArgUsedOutsideOfDef);
                 return false;
             }
             else
 
                     default:
                         {
-                            MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                            MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                             return false;
                         }
                 }
             }
             if (mIndex >= macroArgStack.Peek().Count)
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_NotEnoughMacroArgs, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_NotEnoughMacroArgs);
                 return false;
             }
             result = macroArgStack.Peek()[mIndex];
             return true;
         }
 
-        private bool EvaluateVar(ITree eval, out long result, ref CompError error)
+        private bool EvaluateVar(ITree eval, out long result)
         {
             result = 0;
             var varName = GetGlobalScopedID(eval.Text);
             if (eval == null)
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_UnknownError);
                 return false;
             }
             else if (!variableDict.ContainsKey(varName))
             {
-                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_UnknownArgument);
                 return false;
             }
             else
             }
         }
 
-        private bool EvaluateLiteral(ITree eval, out long result, ref CompError error)
+        private bool EvaluateLiteral(ITree eval, out long result)
         {
             result = 0;
             if (!Utility.NumStringToInt(eval.Text, out result))
             {
-                MakeErrorMessage(eval, ErrorMessage.NumberOverflow, ref error);
+                MakeErrorMessage(eval, ErrorMessage.Build_NumberOverflow);
                 return false;
             }
             return true;
             symFillTable.Add(se);
         }
 
-        private void MakeErrorMessage(SymEntry se, ErrorMessage messageType, ref CompError error)
+        private void MakeErrorMessage(SymEntry se, ErrorMessage messageType)
         {
-            error.errorMessage = messageType;
-            error.lineNumber = se.line;
-            error.characterNumber = se.charpos;
-            error.extraInfo1 = se.label;
+            currentError.errorMessage = messageType;
+            currentError.lineNumber = se.line;
+            currentError.characterNumber = se.charpos;
+            currentError.extraInfo1 = se.label;
         }
 
-        private void MakeErrorMessage(ITree arg, ErrorMessage messageType, ref CompError error)
+        private void MakeErrorMessage(ITree arg, ErrorMessage messageType)
         {
-            error.lineNumber = arg.Line;
-            error.characterNumber = arg.CharPositionInLine;
-            error.errorMessage = messageType;
-            error.extraInfo1 = arg.Text;
+            currentError.lineNumber = arg.Line;
+            currentError.characterNumber = arg.CharPositionInLine;
+            currentError.errorMessage = messageType;
+            currentError.extraInfo1 = arg.Text;
         }
 
-        private void MakeErrorMessage(ErrInfo arg, ref CompError error)
+        private void MakeErrorMessage(ErrInfo arg)
         {
-            error.lineNumber = arg.error.Line;
-            error.characterNumber = arg.error.CharPositionInLine;
-            error.errorMessage = ErrorMessage.General_CustomError;
-            error.extraInfo1 = arg.errText;
+            currentError.lineNumber = arg.error.Line;
+            currentError.characterNumber = arg.error.CharPositionInLine;
+            currentError.errorMessage = ErrorMessage.General_CustomError;
+            currentError.extraInfo1 = arg.errText;
         }
 
-        private bool EvalArithArgFunc(CodeGenerator.ArithmeticFuncDelegate arithFunc, ITree arg, ref CompError error)
+        private bool EvalArithArgFunc(CodeGenerator.ArithmeticFuncDelegate arithFunc, ITree arg)
         {
             var result = 0L;
-            if (!EvaluateExpression(arg.GetChild(0), out result, ref error))
+            if (!EvaluateExpression(arg.GetChild(0), out result))
             {
                 return false;
             }
             return true;
         }
 
-        private bool EvalBitFunc(CodeGenerator.BitFunctionDelegate bitFunc, ITree arg, string reg, ref CompError error)
+        private bool EvalBitFunc(CodeGenerator.BitFunctionDelegate bitFunc, ITree arg, string reg)
         {
             var result = 0L;
-            if (!EvaluateExpression(arg.GetChild(0), out result, ref error))
+            if (!EvaluateExpression(arg.GetChild(0), out result))
             {
                 return false;
             }

gbread/Base/BinFile.cs

             return ret;
         }
 
+        public uint ReadDWord(int offset)
+        {
+            if (binFile == null || offset < 0 || offset > binFile.Length - 2)
+            {
+                return 0xFFFFFFFF;
+            }
+            uint ret = binFile[offset + 4];
+            ret <<= 8;
+            ret |= binFile[offset + 3];
+            ret <<= 8;
+            ret |= binFile[offset + 2];
+            ret <<= 8;
+            ret |= binFile[offset];
+            return ret;
+        }
+
+        public ulong ReadQWord(int offset)
+        {
+            if (binFile == null || offset < 0 || offset > binFile.Length - 2)
+            {
+                return 0xFFFFFFFFFFFFFFFF;
+            }
+            ulong ret = binFile[offset + 7];
+            ret <<= 8;
+            ret |= binFile[offset + 6];
+            ret <<= 8;
+            ret |= binFile[offset + 5];
+            ret <<= 8;
+            ret |= binFile[offset + 4];
+            ret <<= 8;
+            ret |= binFile[offset + 3];
+            ret <<= 8;
+            ret |= binFile[offset + 2];
+            ret <<= 8;
+            ret |= binFile[offset + 1];
+            ret <<= 8;
+            ret |= binFile[offset];
+            return ret;
+        }
+
         public abstract string GetBinInfo();
     }
 }

gbread/Base/DataTemplateLexer.cs

+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     ANTLR Version: 3.4
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+// $ANTLR 3.4 DataTemplate.g 2012-11-06 21:04:37
+
+// The variable 'variable' is assigned but its value is never used.
+#pragma warning disable 219
+// Unreachable code detected.
+#pragma warning disable 162
+// Missing XML comment for publicly visible type or member 'Type_or_Member'
+#pragma warning disable 1591
+// CLS compliance checking will not be performed on 'type' because it is not visible from outside this assembly.
+#pragma warning disable 3019
+
+#pragma warning disable 3021
+
+using System.Collections.Generic;
+using Antlr.Runtime;
+using Antlr.Runtime.Misc;
+
+namespace GBRead.Base
+{
+[System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.4")]
+[System.CLSCompliant(false)]
+public partial class DataTemplateLexer : Antlr.Runtime.Lexer
+{
+	public const int EOF=-1;
+	public const int T__21=21;
+	public const int T__22=22;
+	public const int T__23=23;
+	public const int T__24=24;
+	public const int T__25=25;
+	public const int T__26=26;
+	public const int T__27=27;
+	public const int T__28=28;
+	public const int T__29=29;
+	public const int T__30=30;
+	public const int T__31=31;
+	public const int T__32=32;
+	public const int T__33=33;
+	public const int T__34=34;
+	public const int T__35=35;
+	public const int T__36=36;
+	public const int T__37=37;
+	public const int T__38=38;
+	public const int T__39=39;
+	public const int T__40=40;
+	public const int T__41=41;
+	public const int T__42=42;
+	public const int T__43=43;
+	public const int T__44=44;
+	public const int T__45=45;
+	public const int T__46=46;
+	public const int T__47=47;
+	public const int T__48=48;
+	public const int T__49=49;
+	public const int T__50=50;
+	public const int T__51=51;
+	public const int T__52=52;
+	public const int ARG=4;
+	public const int ARRLEN=5;
+	public const int BIN_DIGIT=6;
+	public const int BIN_NUMBER=7;
+	public const int COMMENT=8;
+	public const int EXPRESSION=9;
+	public const int FIXSTRING=10;
+	public const int HEX_DIGIT=11;
+	public const int HEX_NUMBER=12;
+	public const int INT=13;
+	public const int LITERAL=14;
+	public const int NUMBER=15;
+	public const int OCT_DIGIT=16;
+	public const int OCT_NUMBER=17;
+	public const int ROOT=18;
+	public const int VARSTRING=19;
+	public const int WS=20;
+
+	private List<ErrInfo> Errors = new List<ErrInfo>();
+
+	public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e)
+	{
+		string errHeader = GetErrorHeader(e);
+		string errMSG = GetErrorMessage(e, tokenNames);
+		Errors.Add(new ErrInfo() {errText = errMSG, error = e});
+	}
+
+		public List<ErrInfo> GetErrors()
+	{
+		return Errors;
+	}
+
+
+    // delegates
+    // delegators
+
+	public DataTemplateLexer()
+	{
+		OnCreated();
+	}
+
+	public DataTemplateLexer(ICharStream input )
+		: this(input, new RecognizerSharedState())
+	{
+	}
+
+	public DataTemplateLexer(ICharStream input, RecognizerSharedState state)
+		: base(input, state)
+	{
+
+		OnCreated();
+	}
+	public override string GrammarFileName { get { return "DataTemplate.g"; } }
+
+
+	partial void OnCreated();
+	partial void EnterRule(string ruleName, int ruleIndex);
+	partial void LeaveRule(string ruleName, int ruleIndex);
+
+	partial void EnterRule_T__21();
+	partial void LeaveRule_T__21();
+
+	// $ANTLR start "T__21"
+	[GrammarRule("T__21")]
+	private void mT__21()
+	{
+		EnterRule_T__21();
+		EnterRule("T__21", 1);
+		TraceIn("T__21", 1);
+		try
+		{
+			int _type = T__21;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:25:7: ( '!' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:25:9: '!'
+			{
+			DebugLocation(25, 9);
+			Match('!'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__21", 1);
+			LeaveRule("T__21", 1);
+			LeaveRule_T__21();
+		}
+	}
+	// $ANTLR end "T__21"
+
+	partial void EnterRule_T__22();
+	partial void LeaveRule_T__22();
+
+	// $ANTLR start "T__22"
+	[GrammarRule("T__22")]
+	private void mT__22()
+	{
+		EnterRule_T__22();
+		EnterRule("T__22", 2);
+		TraceIn("T__22", 2);
+		try
+		{
+			int _type = T__22;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:26:7: ( '!=' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:26:9: '!='
+			{
+			DebugLocation(26, 9);
+			Match("!="); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__22", 2);
+			LeaveRule("T__22", 2);
+			LeaveRule_T__22();
+		}
+	}
+	// $ANTLR end "T__22"
+
+	partial void EnterRule_T__23();
+	partial void LeaveRule_T__23();
+
+	// $ANTLR start "T__23"
+	[GrammarRule("T__23")]
+	private void mT__23()
+	{
+		EnterRule_T__23();
+		EnterRule("T__23", 3);
+		TraceIn("T__23", 3);
+		try
+		{
+			int _type = T__23;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:27:7: ( '%' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:27:9: '%'
+			{
+			DebugLocation(27, 9);
+			Match('%'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__23", 3);
+			LeaveRule("T__23", 3);
+			LeaveRule_T__23();
+		}
+	}
+	// $ANTLR end "T__23"
+
+	partial void EnterRule_T__24();
+	partial void LeaveRule_T__24();
+
+	// $ANTLR start "T__24"
+	[GrammarRule("T__24")]
+	private void mT__24()
+	{
+		EnterRule_T__24();
+		EnterRule("T__24", 4);
+		TraceIn("T__24", 4);
+		try
+		{
+			int _type = T__24;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:28:7: ( '&&' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:28:9: '&&'
+			{
+			DebugLocation(28, 9);
+			Match("&&"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__24", 4);
+			LeaveRule("T__24", 4);
+			LeaveRule_T__24();
+		}
+	}
+	// $ANTLR end "T__24"
+
+	partial void EnterRule_T__25();
+	partial void LeaveRule_T__25();
+
+	// $ANTLR start "T__25"
+	[GrammarRule("T__25")]
+	private void mT__25()
+	{
+		EnterRule_T__25();
+		EnterRule("T__25", 5);
+		TraceIn("T__25", 5);
+		try
+		{
+			int _type = T__25;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:29:7: ( '&' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:29:9: '&'
+			{
+			DebugLocation(29, 9);
+			Match('&'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__25", 5);
+			LeaveRule("T__25", 5);
+			LeaveRule_T__25();
+		}
+	}
+	// $ANTLR end "T__25"
+
+	partial void EnterRule_T__26();
+	partial void LeaveRule_T__26();
+
+	// $ANTLR start "T__26"
+	[GrammarRule("T__26")]
+	private void mT__26()
+	{
+		EnterRule_T__26();
+		EnterRule("T__26", 6);
+		TraceIn("T__26", 6);
+		try
+		{
+			int _type = T__26;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:30:7: ( '(' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:30:9: '('
+			{
+			DebugLocation(30, 9);
+			Match('('); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__26", 6);
+			LeaveRule("T__26", 6);
+			LeaveRule_T__26();
+		}
+	}
+	// $ANTLR end "T__26"
+
+	partial void EnterRule_T__27();
+	partial void LeaveRule_T__27();
+
+	// $ANTLR start "T__27"
+	[GrammarRule("T__27")]
+	private void mT__27()
+	{
+		EnterRule_T__27();
+		EnterRule("T__27", 7);
+		TraceIn("T__27", 7);
+		try
+		{
+			int _type = T__27;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:31:7: ( ')' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:31:9: ')'
+			{
+			DebugLocation(31, 9);
+			Match(')'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__27", 7);
+			LeaveRule("T__27", 7);
+			LeaveRule_T__27();
+		}
+	}
+	// $ANTLR end "T__27"
+
+	partial void EnterRule_T__28();
+	partial void LeaveRule_T__28();
+
+	// $ANTLR start "T__28"
+	[GrammarRule("T__28")]
+	private void mT__28()
+	{
+		EnterRule_T__28();
+		EnterRule("T__28", 8);
+		TraceIn("T__28", 8);
+		try
+		{
+			int _type = T__28;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:32:7: ( '*' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:32:9: '*'
+			{
+			DebugLocation(32, 9);
+			Match('*'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__28", 8);
+			LeaveRule("T__28", 8);
+			LeaveRule_T__28();
+		}
+	}
+	// $ANTLR end "T__28"
+
+	partial void EnterRule_T__29();
+	partial void LeaveRule_T__29();
+
+	// $ANTLR start "T__29"
+	[GrammarRule("T__29")]
+	private void mT__29()
+	{
+		EnterRule_T__29();
+		EnterRule("T__29", 9);
+		TraceIn("T__29", 9);
+		try
+		{
+			int _type = T__29;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:33:7: ( '+' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:33:9: '+'
+			{
+			DebugLocation(33, 9);
+			Match('+'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__29", 9);
+			LeaveRule("T__29", 9);
+			LeaveRule_T__29();
+		}
+	}
+	// $ANTLR end "T__29"
+
+	partial void EnterRule_T__30();
+	partial void LeaveRule_T__30();
+
+	// $ANTLR start "T__30"
+	[GrammarRule("T__30")]
+	private void mT__30()
+	{
+		EnterRule_T__30();
+		EnterRule("T__30", 10);
+		TraceIn("T__30", 10);
+		try
+		{
+			int _type = T__30;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:34:7: ( '-' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:34:9: '-'
+			{
+			DebugLocation(34, 9);
+			Match('-'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__30", 10);
+			LeaveRule("T__30", 10);
+			LeaveRule_T__30();
+		}
+	}
+	// $ANTLR end "T__30"
+
+	partial void EnterRule_T__31();
+	partial void LeaveRule_T__31();
+
+	// $ANTLR start "T__31"
+	[GrammarRule("T__31")]
+	private void mT__31()
+	{
+		EnterRule_T__31();
+		EnterRule("T__31", 11);
+		TraceIn("T__31", 11);
+		try
+		{
+			int _type = T__31;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:35:7: ( '/' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:35:9: '/'
+			{
+			DebugLocation(35, 9);
+			Match('/'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__31", 11);
+			LeaveRule("T__31", 11);
+			LeaveRule_T__31();
+		}
+	}
+	// $ANTLR end "T__31"
+
+	partial void EnterRule_T__32();
+	partial void LeaveRule_T__32();
+
+	// $ANTLR start "T__32"
+	[GrammarRule("T__32")]
+	private void mT__32()
+	{
+		EnterRule_T__32();
+		EnterRule("T__32", 12);
+		TraceIn("T__32", 12);
+		try
+		{
+			int _type = T__32;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:36:7: ( ':' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:36:9: ':'
+			{
+			DebugLocation(36, 9);
+			Match(':'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__32", 12);
+			LeaveRule("T__32", 12);
+			LeaveRule_T__32();
+		}
+	}
+	// $ANTLR end "T__32"
+
+	partial void EnterRule_T__33();
+	partial void LeaveRule_T__33();
+
+	// $ANTLR start "T__33"
+	[GrammarRule("T__33")]
+	private void mT__33()
+	{
+		EnterRule_T__33();
+		EnterRule("T__33", 13);
+		TraceIn("T__33", 13);
+		try
+		{
+			int _type = T__33;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:37:7: ( ';' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:37:9: ';'
+			{
+			DebugLocation(37, 9);
+			Match(';'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__33", 13);
+			LeaveRule("T__33", 13);
+			LeaveRule_T__33();
+		}
+	}
+	// $ANTLR end "T__33"
+
+	partial void EnterRule_T__34();
+	partial void LeaveRule_T__34();
+
+	// $ANTLR start "T__34"
+	[GrammarRule("T__34")]
+	private void mT__34()
+	{
+		EnterRule_T__34();
+		EnterRule("T__34", 14);
+		TraceIn("T__34", 14);
+		try
+		{
+			int _type = T__34;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:38:7: ( '<' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:38:9: '<'
+			{
+			DebugLocation(38, 9);
+			Match('<'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__34", 14);
+			LeaveRule("T__34", 14);
+			LeaveRule_T__34();
+		}
+	}
+	// $ANTLR end "T__34"
+
+	partial void EnterRule_T__35();
+	partial void LeaveRule_T__35();
+
+	// $ANTLR start "T__35"
+	[GrammarRule("T__35")]
+	private void mT__35()
+	{
+		EnterRule_T__35();
+		EnterRule("T__35", 15);
+		TraceIn("T__35", 15);
+		try
+		{
+			int _type = T__35;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:39:7: ( '<<' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:39:9: '<<'
+			{
+			DebugLocation(39, 9);
+			Match("<<"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__35", 15);
+			LeaveRule("T__35", 15);
+			LeaveRule_T__35();
+		}
+	}
+	// $ANTLR end "T__35"
+
+	partial void EnterRule_T__36();
+	partial void LeaveRule_T__36();
+
+	// $ANTLR start "T__36"
+	[GrammarRule("T__36")]
+	private void mT__36()
+	{
+		EnterRule_T__36();
+		EnterRule("T__36", 16);
+		TraceIn("T__36", 16);
+		try
+		{
+			int _type = T__36;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:40:7: ( '<=' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:40:9: '<='
+			{
+			DebugLocation(40, 9);
+			Match("<="); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__36", 16);
+			LeaveRule("T__36", 16);
+			LeaveRule_T__36();
+		}
+	}
+	// $ANTLR end "T__36"
+
+	partial void EnterRule_T__37();
+	partial void LeaveRule_T__37();
+
+	// $ANTLR start "T__37"
+	[GrammarRule("T__37")]
+	private void mT__37()
+	{
+		EnterRule_T__37();
+		EnterRule("T__37", 17);
+		TraceIn("T__37", 17);
+		try
+		{
+			int _type = T__37;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:41:7: ( '==' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:41:9: '=='
+			{
+			DebugLocation(41, 9);
+			Match("=="); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__37", 17);
+			LeaveRule("T__37", 17);
+			LeaveRule_T__37();
+		}
+	}
+	// $ANTLR end "T__37"
+
+	partial void EnterRule_T__38();
+	partial void LeaveRule_T__38();
+
+	// $ANTLR start "T__38"
+	[GrammarRule("T__38")]
+	private void mT__38()
+	{
+		EnterRule_T__38();
+		EnterRule("T__38", 18);
+		TraceIn("T__38", 18);
+		try
+		{
+			int _type = T__38;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:42:7: ( '>' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:42:9: '>'
+			{
+			DebugLocation(42, 9);
+			Match('>'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__38", 18);
+			LeaveRule("T__38", 18);
+			LeaveRule_T__38();
+		}
+	}
+	// $ANTLR end "T__38"
+
+	partial void EnterRule_T__39();
+	partial void LeaveRule_T__39();
+
+	// $ANTLR start "T__39"
+	[GrammarRule("T__39")]
+	private void mT__39()
+	{
+		EnterRule_T__39();
+		EnterRule("T__39", 19);
+		TraceIn("T__39", 19);
+		try
+		{
+			int _type = T__39;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:43:7: ( '>=' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:43:9: '>='
+			{
+			DebugLocation(43, 9);
+			Match(">="); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__39", 19);
+			LeaveRule("T__39", 19);
+			LeaveRule_T__39();
+		}
+	}
+	// $ANTLR end "T__39"
+
+	partial void EnterRule_T__40();
+	partial void LeaveRule_T__40();
+
+	// $ANTLR start "T__40"
+	[GrammarRule("T__40")]
+	private void mT__40()
+	{
+		EnterRule_T__40();
+		EnterRule("T__40", 20);
+		TraceIn("T__40", 20);
+		try
+		{
+			int _type = T__40;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:44:7: ( '>>' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:44:9: '>>'
+			{
+			DebugLocation(44, 9);
+			Match(">>"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__40", 20);
+			LeaveRule("T__40", 20);
+			LeaveRule_T__40();
+		}
+	}
+	// $ANTLR end "T__40"
+
+	partial void EnterRule_T__41();
+	partial void LeaveRule_T__41();
+
+	// $ANTLR start "T__41"
+	[GrammarRule("T__41")]
+	private void mT__41()
+	{
+		EnterRule_T__41();
+		EnterRule("T__41", 21);
+		TraceIn("T__41", 21);
+		try
+		{
+			int _type = T__41;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:45:7: ( '?' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:45:9: '?'
+			{
+			DebugLocation(45, 9);
+			Match('?'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__41", 21);
+			LeaveRule("T__41", 21);
+			LeaveRule_T__41();
+		}
+	}
+	// $ANTLR end "T__41"
+
+	partial void EnterRule_T__42();
+	partial void LeaveRule_T__42();
+
+	// $ANTLR start "T__42"
+	[GrammarRule("T__42")]
+	private void mT__42()
+	{
+		EnterRule_T__42();
+		EnterRule("T__42", 22);
+		TraceIn("T__42", 22);
+		try
+		{
+			int _type = T__42;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:46:7: ( '[' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:46:9: '['
+			{
+			DebugLocation(46, 9);
+			Match('['); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__42", 22);
+			LeaveRule("T__42", 22);
+			LeaveRule_T__42();
+		}
+	}
+	// $ANTLR end "T__42"
+
+	partial void EnterRule_T__43();
+	partial void LeaveRule_T__43();
+
+	// $ANTLR start "T__43"
+	[GrammarRule("T__43")]
+	private void mT__43()
+	{
+		EnterRule_T__43();
+		EnterRule("T__43", 23);
+		TraceIn("T__43", 23);
+		try
+		{
+			int _type = T__43;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:47:7: ( ']' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:47:9: ']'
+			{
+			DebugLocation(47, 9);
+			Match(']'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__43", 23);
+			LeaveRule("T__43", 23);
+			LeaveRule_T__43();
+		}
+	}
+	// $ANTLR end "T__43"
+
+	partial void EnterRule_T__44();
+	partial void LeaveRule_T__44();
+
+	// $ANTLR start "T__44"
+	[GrammarRule("T__44")]
+	private void mT__44()
+	{
+		EnterRule_T__44();
+		EnterRule("T__44", 24);
+		TraceIn("T__44", 24);
+		try
+		{
+			int _type = T__44;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:48:7: ( '^' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:48:9: '^'
+			{
+			DebugLocation(48, 9);
+			Match('^'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__44", 24);
+			LeaveRule("T__44", 24);
+			LeaveRule_T__44();
+		}
+	}
+	// $ANTLR end "T__44"
+
+	partial void EnterRule_T__45();
+	partial void LeaveRule_T__45();
+
+	// $ANTLR start "T__45"
+	[GrammarRule("T__45")]
+	private void mT__45()
+	{
+		EnterRule_T__45();
+		EnterRule("T__45", 25);
+		TraceIn("T__45", 25);
+		try
+		{
+			int _type = T__45;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:49:7: ( 'byte' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:49:9: 'byte'
+			{
+			DebugLocation(49, 9);
+			Match("byte"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__45", 25);
+			LeaveRule("T__45", 25);
+			LeaveRule_T__45();
+		}
+	}
+	// $ANTLR end "T__45"
+
+	partial void EnterRule_T__46();
+	partial void LeaveRule_T__46();
+
+	// $ANTLR start "T__46"
+	[GrammarRule("T__46")]
+	private void mT__46()
+	{
+		EnterRule_T__46();
+		EnterRule("T__46", 26);
+		TraceIn("T__46", 26);
+		try
+		{
+			int _type = T__46;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:50:7: ( 'dword' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:50:9: 'dword'
+			{
+			DebugLocation(50, 9);
+			Match("dword"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__46", 26);
+			LeaveRule("T__46", 26);
+			LeaveRule_T__46();
+		}
+	}
+	// $ANTLR end "T__46"
+
+	partial void EnterRule_T__47();
+	partial void LeaveRule_T__47();
+
+	// $ANTLR start "T__47"
+	[GrammarRule("T__47")]
+	private void mT__47()
+	{
+		EnterRule_T__47();
+		EnterRule("T__47", 27);
+		TraceIn("T__47", 27);
+		try
+		{
+			int _type = T__47;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:51:7: ( 'qword' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:51:9: 'qword'
+			{
+			DebugLocation(51, 9);
+			Match("qword"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__47", 27);
+			LeaveRule("T__47", 27);
+			LeaveRule_T__47();
+		}
+	}
+	// $ANTLR end "T__47"
+
+	partial void EnterRule_T__48();
+	partial void LeaveRule_T__48();
+
+	// $ANTLR start "T__48"
+	[GrammarRule("T__48")]
+	private void mT__48()
+	{
+		EnterRule_T__48();
+		EnterRule("T__48", 28);
+		TraceIn("T__48", 28);
+		try
+		{
+			int _type = T__48;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:52:7: ( 'string' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:52:9: 'string'
+			{
+			DebugLocation(52, 9);
+			Match("string"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__48", 28);
+			LeaveRule("T__48", 28);
+			LeaveRule_T__48();
+		}
+	}
+	// $ANTLR end "T__48"
+
+	partial void EnterRule_T__49();
+	partial void LeaveRule_T__49();
+
+	// $ANTLR start "T__49"
+	[GrammarRule("T__49")]
+	private void mT__49()
+	{
+		EnterRule_T__49();
+		EnterRule("T__49", 29);
+		TraceIn("T__49", 29);
+		try
+		{
+			int _type = T__49;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:53:7: ( 'word' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:53:9: 'word'
+			{
+			DebugLocation(53, 9);
+			Match("word"); 
+
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__49", 29);
+			LeaveRule("T__49", 29);
+			LeaveRule_T__49();
+		}
+	}
+	// $ANTLR end "T__49"
+
+	partial void EnterRule_T__50();
+	partial void LeaveRule_T__50();
+
+	// $ANTLR start "T__50"
+	[GrammarRule("T__50")]
+	private void mT__50()
+	{
+		EnterRule_T__50();
+		EnterRule("T__50", 30);
+		TraceIn("T__50", 30);
+		try
+		{
+			int _type = T__50;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:54:7: ( '|' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:54:9: '|'
+			{
+			DebugLocation(54, 9);
+			Match('|'); 
+
+			}
+
+			state.type = _type;
+			state.channel = _channel;
+		}
+		finally
+		{
+			TraceOut("T__50", 30);
+			LeaveRule("T__50", 30);
+			LeaveRule_T__50();
+		}
+	}
+	// $ANTLR end "T__50"
+
+	partial void EnterRule_T__51();
+	partial void LeaveRule_T__51();
+
+	// $ANTLR start "T__51"
+	[GrammarRule("T__51")]
+	private void mT__51()
+	{
+		EnterRule_T__51();
+		EnterRule("T__51", 31);
+		TraceIn("T__51", 31);
+		try
+		{
+			int _type = T__51;
+			int _channel = DefaultTokenChannel;
+			// DataTemplate.g:55:7: ( '||' )
+			DebugEnterAlt(1);
+			// DataTemplate.g:55:9: '||'
+			{
+			DebugLocation(55, 9);
+			Match("||"); 
+
+
+			}