Implementing the Instruction Set - sidprasad/sidbison GitHub Wiki
crule
The crule
command returns the rule being parsed. This command can be mathematically represented as a function
f: (LR Parser Automaton, Current State, State Stack, Token Stack) ->(Backhaus Naur Form Rule)
In general, a bottom-up parser can not predict the non-terminal to which a partially known sequence of tokens will be reduced. Even judging if a reduction will ever take place is a non-decidable problem. As a result, the crule
command cannot be implemented on a single instance of a single-pass parser like Bison.
sidBison implementation tackles this problem by utilizing multiple-passes. A secondary iBison process will run till the first reduce where the current top element of the state stack is popped. The rule reduced is then recorded and passed back to the sidBison program.
steprule
The steprule
command takes the user to the next rule encountered by the parser. It allows the user to step from non-terminal to non-terminal in the parsing process, presenting a step-wise debugging abstraction in terms of the user-provided grammar specification. The command is implemented by stepping through iBison state changes till a reduce action is executed.
rulepos
The rulepos
rule returns possible current positions in the parsing process. It is implemented by displaying all the rules present in the current state in underlying state machine.
str
The str
command returns the current position in the overall parsing process. It is implemented by displaying the contents of the iBison token stack.
ctkn
The ctkn
command displays the token the parser is currently dealing with. It is implemented by presenting either the look-ahead token or the top element of the token stack.
br
The br
command allows the user to break when a particular token is encountered. Its functionality is provided by stepping till the ctkn
is the token provided.