Menu

#3 Does not use ignored alternatives

Parser
open
nobody
3
2005-02-21
2005-02-21
No

Implementation is needlessly complex, as it does not use
sablecc ignored alternatives. Applies to most altered
parts of the grammar.

Discussion

  • Fadi Chabarek

    Fadi Chabarek - 2005-02-21

    Logged In: YES
    user_id=450963

    Date: 2005-02-19 13:20
    Sender: jgsuess
    Logged In: YES
    user_id=557658

    A number of expressions contain tokens which are only used
    in parsing and do not have impact on the AST making it
    needlessly complex.

    Example, commas in param list:
    actual_parameter_list = expression next_expr*;
    next_expr = comma expression;

    What you would want for check and interpretation is an AST
    like this:
    actual_parameter_list = expression+ ;

    Of course, the grammar prevents this. Thus, use an ignored
    alternative and run a tree-transfrom beforehand to get rid of
    the useless tokens and minimize the tree. It pays of later in
    shorter, clearer code (and less stuff in the environment).

    In particular, this also improves the handling of the folowing
    productions:

    logical_expression, boolean_expression, relational_expression,
    compareable_expression, additive_expression,
    multiplicative_expression

    This is, because you do not need to deal differently with the
    first node and the remaining nodes in the recursion tail any
    more. I assume this did not crop up right-away, as the
    processing of tails did not work till recently.

    This is not a bug, but it sure is a design issue for a new
    release.

    For handling of ignored alternatives in the version of sablecc
    used cmp. :

    http://sablecc.org/downloads/thesis.pdf#page=57 (bottom)

    Date: 2005-02-17 01:37
    Sender: fchabar
    Logged In: YES
    user_id=450963

    Basically there is only one change of the grammar, the
    declarator production. The contained expression (and
    subsequently derived productions) is/are used to wrap names
    in declarators. These productions are needed in other parts
    of the AST and can thus not be ignored (but must be checked
    by the parser). Which production do you think must be
    needfully ignored? Could you explain your idea?

     
  • Fadi Chabarek

    Fadi Chabarek - 2005-02-21
    • summary: Implementation is needlessly complex, as it does not use --> Does not use ignored alternatives
     
  • Fadi Chabarek

    Fadi Chabarek - 2005-02-21
    • milestone: --> Parser
    • priority: 5 --> 3
     

Log in to post a comment.