public FiniteStateMachine(GrammarRules grammarRules, Preprocessor preprocessor, bool isClr)
 {
     _grammarRules = grammarRules;
     _isClr        = isClr;
     States        = new HashSet <State>();
     _preprocessor = preprocessor;
 }
 public LeftToRight_RightMost_Zero(GrammarRules grammarRules, LRType lrType, Preprocessor preprocessor)
 {
     _grammarRules      = grammarRules;
     _lrType            = lrType;
     _preprocessor      = preprocessor;
     MapperToNumber     = new MapperToNumber(_grammarRules);
     FiniteStateMachine = new FiniteStateMachine(_grammarRules, _preprocessor, lrType == LRType.ClR_One);
     Nodes = new Stack <TreeNode>();
 }
Beispiel #3
0
 public LeftToRight_LookAhead_One(GrammarRules grammarRules, IProgress <ParseReportModel> progress)
 {
     treeNodes = new Stack <TreeNode>();
     BaseNode  = new TreeNode(grammarRules.HeadVariable, _orderId);
     treeNodes.Push(BaseNode);
     _grammarRules  = grammarRules;
     _progress      = progress;
     MapperToNumber = new MapperToNumber(_grammarRules);
 }
Beispiel #4
0
        private void btnParseGrammar_Click(object sender, EventArgs e)
        {
            listBoxGrammar.Items.Clear();
            listBoxFirst.Items.Clear();
            if (string.IsNullOrEmpty(txtgrammarFile.Text))
            {
                MessageBox.Show("Grammar file is empty!");
                return;
            }
            var             text = File.ReadAllText(txtgrammarFile.Text);
            LexicalAnalyzer lex  = new LexicalAnalyzer(text);

            RestartStopWatch();
            _grammarRules = lex.TokenizeGrammar();
            _stopwatch.Stop();
            lblTime.Text = $"Tokenizing process took {_stopwatch.ElapsedMilliseconds} ms.";
            foreach (ISymbol symbol in _grammarRules.SymbolList)
            {
                if (symbol.SymbolType == SymbolType.Variable)
                {
                    listBoxGrammar.Items.Add(((Variable)symbol).ShowRules());
                }
            }
        }
Beispiel #5
0
 public MapperToNumber(GrammarRules grammarRules)
 {
     _grammarRules       = grammarRules;
     MapTerminalToNumber = new Dictionary <string, int>();
     MapVariableToNumber = new Dictionary <string, int>();
 }
 public SyntaxRules(string value, int type)
 {
     _value = value;
     _type  = (GrammarRules)type;
 }
Beispiel #7
0
 public LexicalAnalyzer(string data)
 {
     Data          = data;
     _grammarRules = new GrammarRules();
 }
Beispiel #8
0
 public Preprocessor(GrammarRules grammarRules)
 {
     GrammarRules = grammarRules;
 }