PreviousUpNext

14.5.19  Lr_Parser

The standard library Lr_Parser api defines part of the yacc parser-generator suite.

The Lr_Parser api source code is in src/app/yacc/lib/base.api.

The above information is manually maintained and may contain errors.

api {
    package stream : api {
                         Stream X;
                         streamify : (Void -> X) -> Stream(X );
                         cons : (X , Stream(X )) -> Stream(X );
                         get : Stream(X ) -> (X , Stream(X ));
                     };;
    package lr_table : api {
                           Pairlist (X, Y) = EMPTY | PAIR (X , Y , Pairlist((X, Y) ));
                           State  = STATE Int;
                           Terminal  = TERM Int;
                           Nonterminal  = NONTERM Int;
                           Action  = ACCEPT | ERROR | REDUCE Int | SHIFT State;
                           Table ;
                           state_count : Table -> Int;
                           rule_count : Table -> Int;
                           describe_goto : Table -> State -> Pairlist((Nonterminal, State) );
                           action : Table -> (State , Terminal) -> Action;
                           goto : Table -> (State , Nonterminal) -> State;
                           initial_state : Table -> State;
                           describe_actions : Table
                                              -> State -> (Pairlist((Terminal, Action) ) , Action);
                           exception GOTO (State , Nonterminal);
                           make_lr_table : {actions:Rw_Vector(((Pairlist((Terminal, Action) ) , Action)) ), 
                                            gotos:Rw_Vector(Pairlist((Nonterminal, State) ) ), 
                                            initial_state:State,  rule_count:Int, 
                                            state_count:Int}
                                           -> Table;
                       };;
    package token : api {
                        package lr_table : api {
                                               Pairlist (X, Y) = EMPTY | PAIR (X , Y , Pairlist((X, Y) ));
                                               State  = STATE Int;
                                               Terminal  = TERM Int;
                                               Nonterminal  = NONTERM Int;
                                               Action  = ACCEPT | ERROR | REDUCE Int | SHIFT State;
                                               Table ;
                                               state_count : Table -> Int;
                                               rule_count : Table -> Int;
                                               describe_goto : Table -> State -> Pairlist((Nonterminal, State) );
                                               action : Table -> (State , Terminal) -> Action;
                                               goto : Table -> (State , Nonterminal) -> State;
                                               initial_state : Table -> State;
                                               describe_actions : Table
                                                                  -> State -> (Pairlist((Terminal, Action) ) , Action);
                                               exception GOTO (State , Nonterminal);
                                               make_lr_table : {actions:Rw_Vector(((Pairlist((Terminal, Action) ) , Action)) ), 
                                                                gotos:Rw_Vector(Pairlist((Nonterminal, State) ) ), 
                                                                initial_state:State,  rule_count:Int, 
                                                                state_count:Int}
                                                               -> Table;
                                           };;
                        Token (X, Y)
                          = TOKEN (lr_table::Terminal , ((X , Y , Y)));
                        same_token : (Token((X, Y) ) , Token((X, Y) )) -> Bool;
                    };;
    exception PARSE_ERROR;
    parse : {arg:X, 
             error_recovery:{error:(String , Z , Z) -> Void, 
                             errtermvalue:lr_table::Terminal -> Y, 
                             is_keyword:lr_table::Terminal -> Bool, 
                             no_shift:lr_table::Terminal -> Bool, 
                             preferred_change:List(
                                                ((List(lr_table::Terminal ) , List(lr_table::Terminal )))
                                                ), 
                             show_terminal:lr_table::Terminal -> String, 
                             terms:List(lr_table::Terminal )}, 
             lexer:stream::Stream(token::Token((Y, Z) ) ),  lookahead:Int, 
             saction:(Int , Z , List(((lr_table::State , ((Y , Z , Z)))) )
                      , X)
                     -> (lr_table::Nonterminal , ((Y , Z , Z))
                         , List(((lr_table::State , ((Y , Z , Z)))) )), 
             table:lr_table::Table,  void:Y}
            -> (Y , stream::Stream(token::Token((Y, Z) ) ));
sharing token::lr_table = lr_table
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext