2013-09-05 7 views
0

내가코드 colorizer 오류

b.a := 7; 

내 문법과 같은 문을 구문 분석 문법을 쓰기 위해 노력하고 있어요 그것은 내가

을 구문 분석하려고 할 때 잘 작동

public class STGrammar : InterpretedLanguageGrammar 
{ 
    public STGrammar() : base(caseSensitive: false) 
    { 
     LanguageFlags = LanguageFlags.CreateAst; 

     # region Terminals 
     Terminal n = new NumberLiteral("number"); 
     Terminal v = new IdentifierTerminal("variable"); 
     KeyTerm assignment = ToTerm(":="); 
     KeyTerm left_paren = ToTerm("("); 
     KeyTerm right_paren = ToTerm(")"); 
     KeyTerm terminate = ToTerm(";"); 
     KeyTerm left_sq = ToTerm("["); 
     KeyTerm right_sq = ToTerm("]"); 
     KeyTerm dot = ToTerm("."); 
     #endregion Terminals 

     #region Nonterminals 
     NonTerminal actionBlock = new NonTerminal("actionBlock", typeof(ActionBlock)); 
     NonTerminal assignmentExpr = new NonTerminal("assignmentExpr", typeof(AssignmentStNode)); 
     NonTerminal arrayOrStruct = new NonTerminal("arrayOrStruct", typeof(ArrayNode)); 
     NonTerminal arrayOrStructRHS = new NonTerminal("arrayOrStructRHS", typeof(AstNode)); 
     NonTerminal arrayOrStructRHSs = new NonTerminal("arrayOrStructRHSs"); 
     NonTerminal comparatorExp = new NonTerminal("comparatorExpression", typeof(ExpressionNode)); 
     #endregion Nonterminals 

     #region BNFRules 
     actionBlock.Rule = 
      assignmentExpr + terminate 
      | arrayOrStruct + terminate 
      ; 
     assignmentExpr.Rule = 
      v + assignment + v 
      | v + assignment + n 
      | arrayOrStruct + assignment + v 
      | v + assignment + arrayOrStruct 
      | arrayOrStruct + assignment + arrayOrStruct 
      | arrayOrStruct + assignment + n 
      ; 
     arrayOrStruct.Rule = 
      v + arrayOrStructRHSs 
      ; 
     arrayOrStructRHS.Rule = 
      "." + v 
      | "[" + v + "]" 
      ; 
     arrayOrStructRHSs.Rule = 
      MakePlusRule(arrayOrStructRHSs, arrayOrStructRHS) 
      ; 

     this.Root = actionBlock; 

     #endregion BNFRules 

     MarkPunctuation(",", ";", "[", "]", ")", "(", "..", "."); 
     RegisterBracePair("(", ")"); 
    } 
} 

아래와 같습니다

b := 7; 

올 오류는 Fatal Error in code colorizer. Colorizing had been disabled.입니다. 댓글을 달았을지라도

LanguageFlags = LanguageFlags.CreateAst; 

오류가 계속 발생합니다. 자세한 오류가

System.NullReferenceException was unhandled by user code 
    Message=Object reference not set to an instance of an object. 
    Source=Irony 
    StackTrace: 
     at Irony.Ast.AstBuilder.BuildAst(ParseTreeNode parseNode) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Ast\AstBuilder.cs:line 97 
     at Irony.Ast.AstBuilder.BuildAst(ParseTreeNode parseNode) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Ast\AstBuilder.cs:line 86 
     at Irony.Ast.AstBuilder.BuildAst(ParseTreeNode parseNode) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Ast\AstBuilder.cs:line 86 
     at Irony.Ast.AstBuilder.BuildAst(ParseTreeNode parseNode) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Ast\AstBuilder.cs:line 86 
     at Irony.Ast.AstBuilder.BuildAst(ParseTree parseTree) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Ast\AstBuilder.cs:line 38 
     at Irony.Interpreter.InterpretedLanguageGrammar.BuildAst(LanguageData language, ParseTree parseTree) in C:\Sreeja\downloads\Irony_2013_03_10\Irony.Interpreter\InterpretedLanguageGrammar.cs:line 60 
     at Irony.Parsing.Parser.Parse(String sourceText, String fileName) in C:\Sreeja\downloads\Irony_2013_03_10\Irony\Parsing\Parser\Parser.cs:line 88 
     at Irony.GrammarExplorer.fmGrammarExplorer.ParseSample() in C:\Sreeja\downloads\Irony_2013_03_10\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 348 
     at Irony.GrammarExplorer.fmGrammarExplorer.btnParse_Click(Object sender, EventArgs e) in C:\Sreeja\downloads\Irony_2013_03_10\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 507 
     at System.Windows.Forms.Control.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
     at System.Windows.Forms.Button.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
    InnerException: 

누군가가 나에게 오류를 해결하는 데 도움이 수

입니까? Irony_2013_03_10 버전을 사용하고 있습니다.

답변

0

임시 노드를 제외한 모든 비 터미널 노드에 대해 Ast 노드 유형을 추가해야합니다. 각 Ast 노드 클래스에서는 Init() 및 DoEvalute() 함수를 재정의합니다. 자세한 내용은 this discussion

에서 찾을 수 있습니다.