Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

再帰的に呼ばれる場合の表現 #34

Open
RYOSKATE opened this issue Jul 27, 2016 · 0 comments
Open

再帰的に呼ばれる場合の表現 #34

RYOSKATE opened this issue Jul 27, 2016 · 0 comments

Comments

@RYOSKATE
Copy link
Contributor

C/C++のg4ファイルだと例えば以下のように
本来ならそれぞれUniUnaryOp,UniFieldAccess,UniMethodCall,UniCast,UniBinOpなどにしたいものが一箇所にまとまっており現在はとりあえず全てUniBinOpとして認識させている。

postfixexpression => UniBinOp
:
    primaryexpression$RETURN
    | postfixexpression$left LeftBracket$operator assignmentexpression$right RightBracket$operator
    | postfixexpression '[' bracedinitlist ']'
    | postfixexpression$left LeftParen$operator expressionlist?$right RightParen$operator
    | simpletypespecifier '(' expressionlist? ')'
    | typenamespecifier '(' expressionlist? ')'
    | simpletypespecifier bracedinitlist
    | typenamespecifier bracedinitlist
    | postfixexpression$left Dot$operator Template? idexpressionlapper$right
    | postfixexpression$left Arrow$operator Template? idexpressionlapper$right
    | postfixexpression$left Dot$operator pseudodestructorname$right
    | postfixexpression$left Arrow$operator pseudodestructorname$right
    | postfixexpression '++'
    | postfixexpression '--'
    | Dynamic_cast '<' typeid '>' '(' expression ')'
    | Static_cast '<' typeid '>' '(' expression ')'
    | Reinterpret_cast '<' typeid '>' '(' expression ')'
    | Const_cast '<' typeid '>' '(' expression ')'
    | Typeid '(' expression ')'
    | Typeid '(' typeid ')'
;

これを例えば以下のようにしてもpostfixexpressionが再帰的に呼ばれる場合のためか認識されない。


postfixexpression => UniBinOp
:
    primaryexpression$RETURN
    | fieldaccessexpression$RETURN
    | postfixexpression '[' bracedinitlist ']'
    | methodcallexpression$RETURN
    | simpletypespecifier bracedinitlist
    | typenamespecifier bracedinitlist
    | postincrementexpression$RETURN
    | Dynamic_cast '<' typeid '>' '(' expression ')'
    | Static_cast '<' typeid '>' '(' expression ')'
    | Reinterpret_cast '<' typeid '>' '(' expression ')'
    | Const_cast '<' typeid '>' '(' expression ')'
    | Typeid '(' expression ')'
    | Typeid '(' typeid ')'
;
fieldaccessexpression => UniFieldAccess
:
       postfixexpression$fieldName LeftBracketassignmentexpression$index RightBracket
    | postfixexpression$receiver DotTemplate? idexpressionlapper$fieldName
    | postfixexpression$receiver ArrowTemplate? idexpressionlapper$fieldName
    | postfixexpression$receiver Dotpseudodestructorname$fieldName
    | postfixexpression$receiver Arrowpseudodestructorname$fieldName
;
methodcallexpression => UniMethodCall
:
       postfixexpression$methodName '(' expressionlist?$args ')'
    | simpletypespecifier$methodName '(' expressionlist?$args ')'
    | typenamespecifier$methodName '(' expressionlist?$args ')'
;

postincrementexpression => UniUnaryOp
:
       postfixexpression$value PlusPlus$operator
    | postfixexpression$value MinusMinus$operator
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant