コード例 #1
1
ファイル: QueryParser.cs プロジェクト: yetanotherchris/spruce
 public static void InitializeReader()
 {
     using (Stream stream = typeof(QueryParser).Assembly.GetManifestResourceStream("Spruce.Core.Search.Grammar.spruce.cgt"))
     {
         // Parse the compiled grammar file
         _grammarReader = new CGTReader(stream);
     }
 }
コード例 #2
0
        private void Init(Stream stream)
        {
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();
            parser.TrimReductions = false;
            parser.StoreTokens    = LALRParser.StoreTokensMode.NoUserObject;

            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);
        }
コード例 #3
0
        private void Init(Stream stream)
        {
            numberFormatInfo = new NumberFormatInfo();
            numberFormatInfo.NumberDecimalSeparator = ".";
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();
            parser.TrimReductions = false;
            parser.StoreTokens    = LALRParser.StoreTokensMode.NoUserObject;

            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);
        }
コード例 #4
0
ファイル: V20Parser.cs プロジェクト: ufjl0683/sshmc
        private void Init(Stream stream)
        {
            CGTReader reader = new CGTReader(stream);
            parser = reader.CreateNewParser();
            parser.TrimReductions = false;
            parser.StoreTokens = LALRParser.StoreTokensMode.NoUserObject;

            parser.OnReduce += new LALRParser.ReduceHandler(ReduceEvent);
            parser.OnTokenRead += new LALRParser.TokenReadHandler(TokenReadEvent);
            parser.OnAccept += new LALRParser.AcceptHandler(AcceptEvent);
            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);
        }
コード例 #5
0
        private void Init(Stream stream)
        {
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();

            parser.StoreTokens = LALRParser.StoreTokensMode.NoUserObject;
            parser.TrimReductions = false;
            parser.OnReduce += new LALRParser.ReduceHandler(ReduceEvent);
            parser.OnTokenRead += new LALRParser.TokenReadHandler(TokenReadEvent);
            parser.OnAccept += new LALRParser.AcceptHandler(AcceptEvent);
            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);

            Configuration config = null;

            // check to see if config is already loaded
            // if NOT then load default
            try
            {
                config = Configuration.GetNewInstance();

                if (config == null)
                {
                    Configuration.Load(Configuration.DefaultConfigurationPath);
                }
            }
            catch
            {
                // It may throw an error in the Configuration.GetNewInstanc()
                // so try this from the default config path
                Configuration.Load(Configuration.DefaultConfigurationPath);
            }

            mContext = new Rule_Context();

            // this is done to ensure that the encourage copying of the Epi.Analysis.Statistics dll
            // to the build folder;
            //System.Console.WriteLine(Epi.Analysis.Statistics.Frequency.Equals(null,null));
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: langpavel/LPS-old
 private void OpenGrammar()
 {
     if (openGrammarDialog.ShowDialog() == DialogResult.OK)
     {
         settings.LastGrammar = openGrammarDialog.FileName;
         SaveSettings();
         WriteLn("Reading file...");
         long t1 = DateTime.Now.Ticks;
         try
         {
             CGTReader reader = new CGTReader(openGrammarDialog.FileName);
             parser = reader.CreateNewParser();
             parser.OnTokenRead += new LALRParser.TokenReadHandler(TokenReadEvent);
             parser.OnShift += new LALRParser.ShiftHandler(ShiftEvent);
             parser.OnReduce += new LALRParser.ReduceHandler(ReduceEvent);
             parser.OnGoto += new LALRParser.GotoHandler(GotoEvent);
             parser.OnAccept += new LALRParser.AcceptHandler(AcceptEvent);
             parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
             parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);
             parser.OnCommentRead += new LALRParser.CommentReadHandler(CommentReadEvent);
             long t2 = DateTime.Now.Ticks;
             WriteLn(String.Format("Reading the Compiled Grammar Table File took {0}ms",(t2-t1)/10000));
         }
         catch (Exception e)
         {
             WriteLn(e.Message);
         }
     }
 }
コード例 #7
0
        private void Init(Stream stream, IScope pScope = null)
        {
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();

            parser.StoreTokens = LALRParser.StoreTokensMode.NoUserObject;
            parser.TrimReductions = false;
            parser.OnReduce += new LALRParser.ReduceHandler(ReduceEvent);
            parser.OnTokenRead += new LALRParser.TokenReadHandler(TokenReadEvent);
            parser.OnAccept += new LALRParser.AcceptHandler(AcceptEvent);
            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);

            Configuration config = null;

            // check to see if config is already loaded
            // if NOT then load default
            try
            {
                config = Configuration.GetNewInstance();

                if (config == null)
                {
                    Configuration.Load(Configuration.DefaultConfigurationPath);
                }
            }
            catch
            {
                // It may throw an error in the Configuration.GetNewInstanc()
                // so try this from the default config path
                Configuration.Load(Configuration.DefaultConfigurationPath);
            }
            if (pScope == null)
            {
                RuleContext = new Rule_Context();
            }
            else
            {
                RuleContext = new Rule_Context(pScope);
            }
        }
コード例 #8
0
ファイル: CalcParserV2.cs プロジェクト: langpavel/LPS-old
        private void Init(Stream stream)
        {
            numberFormatInfo = new NumberFormatInfo();
            numberFormatInfo.NumberDecimalSeparator = ".";
            CGTReader reader = new CGTReader(stream);
            parser = reader.CreateNewParser();
            parser.TrimReductions = false;
            parser.StoreTokens = LALRParser.StoreTokensMode.NoUserObject;

            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);
        }