Пример #1
0
 void IParserPostProcessor.Postprocess(ParserPostProcessParams postProcessorParams)
 {
     context_ = new TreeContext(postProcessorParams);
     string outDir =PUtils.MakeFileName("", context_.generatorParams_.outputDirectory_, "DefiniteLengthForm");
     if (!Directory.Exists(outDir))
     {
         Directory.CreateDirectory(outDir);
     }
     string outFile= PUtils.MakeFileName(context_.generatorParams_.sourceFileTitle_,outDir);
     using (BinaryWriter rw = new BinaryWriter(File.Open(outFile, FileMode.Create)))
     {
         WriteDefinite(rw, context_.generatorParams_.root_);
         context_.generatorParams_.errOut_.WriteLine("INFO  from <BER_DEFINITE_ENCODER> {0} bytes written to '{1}'",
                                      rw.BaseStream.Position,outFile);
     }
 }
Пример #2
0
 internal NormalizeTree(TreeContext c, HashSet<string> setRules)
 {
     c_ = c;
     bOk_ = true;
     setRules_ = setRules;
     PegNode rule = PUtils.GetRuleFromRoot(c_.root_);
     PegNode specification = PUtils.GetPegSpecification(c_.root_);
     TranslateMandatoryToFatal(rule);
     InsertMissingRuleIds(rule);
     new TryFuseCharsets(this, rule);
     LinkIntoVariablesToSemanticBlocks(rule);
     new GenericParameters(this, rule);
     new SemanticFunctions(this, rule);
     //InsertMissingEnumerations(rule,specification);
 }
Пример #3
0
 void IParserPostProcessor.Postprocess(ParserPostProcessParams postProcessorParams)
 {
     TreeContext context = new TreeContext(postProcessorParams);
     var checker = new CheckGrammar(context);
     if (!checker.bOk_) return;
     var normalize = new NormalizeTree(context,checker.setRules_);
     if (!normalize.bOk_) return;
     Peg.CSharp.PegCSharpGenerator cSharpGenerator = new Peg.CSharp.PegCSharpGenerator(context);
 }
Пример #4
0
 void CheckDoubleDefinitions(TreeContext c, PegNode n)
 {
     for (; n != null; n = n.next_)
     {
         Debug.Assert(n.id_ == (int)EPegGrammar.peg_rule);
         string ruleName = PUtils.GetRuleNameFromRule(n, c_.src_);
         if (setRules_.Contains(ruleName))
         {
             bOk_ = false;
             c.errOut_.WriteLine(c.sErrorPrefix + "ERRROR: rule <" + ruleName + "> is duplicate");
         }
         else
         {
             setRules_.Add(ruleName);
         }
     }
 }
Пример #5
0
 void CheckDoubleDefinitions(TreeContext c)
 {
     CheckDoubleDefinitions(c, PUtils.GetRuleFromRoot(c.root_));
 }
Пример #6
0
 internal CheckGrammar(TreeContext c)
 {
     c_ = c;
     bOk_ = true;
     setRules_ = new HashSet<string>();
     PegNode n = PUtils.GetRuleFromRoot(c.root_);
     if (n == null) return;
     Debug.Assert(n.id_ == (int)EPegGrammar.peg_rule);
     CheckDoubleDefinitions(c);
     /*
     m_bIsTopModule = true;
     CheckReferenceDefined(c.m_context);
     m_bIsTopModule = true;
     CheckLeftRecursiveness(c.m_context);
      * */
 }