Share

LALR Parser Generator

Subscribe

PHP new if else grammar

You are viewing a single message from this topic. View all messages.

  1. 2009-10-27 19:00:40 UTC

    Is it possible make following grammar LALR(k):

    Goal ::= ')' statement_full
    
    statement_full ::= if_statement_full
        | newif_statement
    
    if_statement_full ::= 'if' '(' expr ')' statement_full
        | 'if' '(' expr ')' statement_noShortIf 'else' statement_full
        | 'if' '(' expr ')' statement_noShortIf elseif_list_full
        | 'if' '(' expr ')' statement_noShortIf elseif_list_noShortIf 'else' statement_full
    
    statement_noShortIf ::= if_statement_noShortIf
        | newif_statement
    
    if_statement_noShortIf ::= 'if' '(' expr ')' statement_noShortIf 'else' statement_noShortIf
        | 'if' '(' expr ')' statement_noShortIf elseif_list_noShortIf 'else' statement_noShortIf
    
    elseif_list_noShortIf ::= else_if_noShortIf
        | elseif_list_noShortIf else_if_noShortIf
    
    else_if_noShortIf ::= 'elseif' '(' expr ')' statement_noShortIf
    
    newif_statement ::= 'if' '(' expr ')' ':' inner_statement_list new_elseif_list new_else_single 'endif' ';'
    
    inner_statement_list ::= %Empty
        | inner_statement_list inner_statement
    
    inner_statement ::= statement_full
    
    new_elseif_list ::= %Empty
        | new_elseif_list 'elseif' '(' expr ')' ':' inner_statement_list
    
    new_else_single ::= %Empty
        | 'newelse' ':' inner_statement_list
    
    elseif_list_full ::= else_if_full
        | elseif_list_noShortIf else_if_full
    
    else_if_full ::= 'elseif' '(' expr ')' statement_full
    
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.