Beispiel #1
0
 public void AddJsonValue(string key, JsonValue value)
 {
     if (!Values.ContainsKey(key))
     {
         Values.Add(key, value);
     }
     else
     {
         throw new Exception("This key already contain value");
     }
 }
Beispiel #2
0
 void GenerateAstJson(AstBuilder astBuilder, ITextOutput output)
 {
     var visitor = new AstCsToJsonVisitor(output);
     astBuilder.SyntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
     astBuilder.SyntaxTree.AcceptVisitor(visitor);
     AstCsToJsonVisitor visit = visitor as AstCsToJsonVisitor;
     if (visit != null)
     {
         result = visit.LastValue;
     }
     else
     {
         result = null;
     } 
 }
Beispiel #3
0
 public void AddJsonValue(JsonValue value)
 {
     ValueList.Add(value);
 }
Beispiel #4
0
 private void Push(JsonValue value)
 {
     jsonValueStack.Push(value);
 }
Beispiel #5
0
        public void VisitSyntaxTree(SyntaxTree syntaxTree)
        {
            JsonArray arr = new JsonArray();
            arr.Comment = "VisitSyntaxTree";
            int counter = 0;
            CreateGlobalSymbolTable();

            foreach (AstNode node in syntaxTree.Children)
            {
                node.AcceptVisitor(this);
                arr.AddJsonValue(Pop());
                counter++;
            }


            //-----------
            //type reference table
            JsonObject symbolInformations = new JsonObject();
            JsonArray typerefs = new JsonArray();
            symbolInformations.AddJsonValue("typerefs", typerefs);
            foreach (string k in this.typeReferences.Keys)
            {
                //type reference
                typerefs.AddJsonValue(new JsonElement(k));
            }
            arr.AddJsonValue(symbolInformations);
            //-----------

            if (counter == 1)
            {
                LastValue = arr.ValueList[0];
            }
            else
            {
                LastValue = arr;
            }
        }