예제 #1
0
 private void BuildSerializedNumbers(CPreProcessor processor)
 {
     Interpreter runtime = new Interpreter();
     foreach (string key in processor.PreProcMacros.Keys)
     {
         PreprocMacro m = processor.PreProcMacros[key];
         if (m.Definition != null)
         {
             // hack.
             string definition = StripEverything(m.Definition);
             if (definition != "")
             {
                 Parser p = new Parser();
                 Operation node = p.Parse(definition);
                 if (node != null)
                 {
                     runtime.Reset();
                     Value v = node.Evaluate(runtime);
                     if (v != null)
                     {
                         SerializedNumber n = v.Serialized;
                         if (n != null)
                         {
                             n.Name = key;
                             Numbers.Add(n);
                             Trace.TraceInformation("Define {0} as {1}.", key, n);
                         }
                     }
                     else
                     {
                         Trace.TraceError("Unable to evaluate: {0} [{1}]", definition, m.Definition);
                     }
                 }
                 else
                 {
                     Trace.TraceError("Unable to parse: {0} [{1}]", definition, m.Definition);
                 }
             }
         }
     }
 }
예제 #2
0
 public PreprocReader(CPreProcessor processor)
 {
     Processor = processor;
 }
예제 #3
0
 public int Compile(string filename, CPreProcessor processor)
 {
     Numbers = new List<SerializedNumber>();
     BuildSerializedNumbers(processor);
     return CompileNumbers(filename);
 }