public void ParsingSteps( Syntan.SyntacticAnalysis.ExtendedGrammar grammar, Syntan.SyntacticAnalysis.LR.ParserTable table, IEnumerable<Syntan.SyntacticAnalysis.TerminalSymbol> input, IEnumerable<Fixtures.ParsingStepData> expected_parsing_steps) { var p = new Parser(); p.Start(grammar, table, input); foreach( var step in expected_parsing_steps ) { Assert.Equal(step.Phase, p.Phase); Assert.Equal(step.IsParsing, p.IsParsing); Assert.Equal(step.IsFinished, p.IsFinished); Assert.Equal(step.StepCount, p.StepCount); Assert.Equal(step.CurrentState, p.CurrentState); Assert.Equal(step.CurrentInputSymbol, p.CurrentInputSymbol); Assert.Equal(step.ActionArgument, p.ActionArgument); if( step.AreReductionPropertiesSet ) { Assert.Equal(step.GotoState, p.GotoState); Assert.Equal(step.GotoSymbol, p.GotoSymbol); Assert.Equal(step.ReductionRule, p.ReductionRule); } p.StepPhase(); } }
public void SetpAfterAccept() { var p = new Parser(); p.Start( Fixtures.EmptyGrammar.ExtendedGrammar, Fixtures.EmptyGrammar.SLR1ParserTable, new Syntan.SyntacticAnalysis.TerminalSymbol[] { Fixtures.EmptyGrammar.ExtendedGrammar.EndOfSourceSymbol }); Assert.Throws<InvalidOperationException>( () => p.StepPhase() ); }
public void StepWhenNotParsing() { var p = new Parser(); Assert.Throws<InvalidOperationException>( () => p.StepPhase() ); }
public void StepAfterError() { var p = new Parser(); p.Start( Fixtures.Grammar2.ExtendedGrammar, Fixtures.Grammar2.SLR1ParserTable, new TerminalSymbol[] { Fixtures.Grammar2.ExtendedGrammar.EndOfSourceSymbol }); Assert.Throws<InvalidOperationException>( () => p.StepPhase() ); }