huntzhan / clidoc

Prove Of Conecept Fork Of Docopt.
MIT License
7 stars 1 forks source link

CFG severe error. #57

Closed huntzhan closed 9 years ago

huntzhan commented 9 years ago
Usage: *UTILITY_DELIMITER* --mode | -m <mode> 

Doc(
| LogicXor(
| | LogicXor(
| | | LogicAnd(
| | | | LogicAnd(
| | | | | GnuOption[--mode]
| | | | )
| | | )
| | | LogicAnd(
| | | | LogicAnd(
| | | | | PosixOption[-m]
| | | | )
| | | | LogicAnd(
| | | | | Argument[<mode>]
| | | | )
| | | )
| | )
| )
)

[AST]
Doc(
| LogicXor(
| | GnuOption[--mode]
| | LogicAnd(
| | | PosixOption[-m]
| | | Argument[<mode>]
| | )
| )

Reason: _singleutility should not derive _xorexprs.

utilities          : utilities single_utility
                   | single_utility
;
single_utility     : K_UTILITY_DELIMITER xor_exprs
;
xor_exprs          : xor_exprs K_EXCLUSIVE_OR seqs
                   | seqs
;
seqs               : seqs single_seq
                   | single_seq
;
single_seq         : atom
                   | atom K_ELLIPSES
;
atom               : K_L_PARENTHESIS xor_exprs K_R_PARENTHESIS
                   | K_L_BRACKET xor_exprs K_R_BRACKET
                   | posix_option_unit
                   | gnu_option_unit
                   | ARGUMENT
                   | COMMAND
                   | K_OPTIONS
                   | K_DOUBLE_HYPHEN
;
huntzhan commented 9 years ago

increase precedence of ....

Grammar

    0 $accept: doc END

    1 doc: usage_section options_section

    2 usage_section: K_USAGE_COLON utilities

    3 utilities: utilities single_utility
    4          | single_utility

    5 single_utility: K_UTILITY_DELIMITER seqs

    6 seqs: seqs single_seq
    7     | single_seq

    8 single_seq: logic
    9           | logic K_ELLIPSES
   10           | xor_expr
   11           | atom

   12 logic: and_expr
   13      | optional_expr

   14 and_expr: K_L_PARENTHESIS seqs K_R_PARENTHESIS

   15 optional_expr: K_L_BRACKET seqs K_R_BRACKET

   16 xor_expr: _xor_expr K_EXCLUSIVE_OR atom

   17 _xor_expr: _xor_expr K_EXCLUSIVE_OR atom
   18          | atom

   19 atom: posix_option_unit
   20     | gnu_option_unit
   21     | ARGUMENT
   22     | ARGUMENT K_ELLIPSES
   23     | COMMAND
   24     | K_OPTIONS
   25     | K_DOUBLE_HYPHEN

   26 posix_option_unit: POSIX_OPTION
   27                  | POSIX_OPTION K_ELLIPSES
   28                  | GROUPED_OPTIONS
   29                  | GROUPED_OPTIONS K_ELLIPSES

   30 gnu_option_unit: GNU_OPTION
   31                | GNU_OPTION K_ELLIPSES
   32                | GNU_OPTION K_EQUAL_SIGN ARGUMENT
   33                | GNU_OPTION K_EQUAL_SIGN ARGUMENT K_ELLIPSES

   34 options_section: K_OPTIONS_COLON descriptions
   35                | %empty

   36 descriptions: descriptions single_description
   37             | single_description

   38 single_description: bindings default_value K_DESC_DELIMITER
   39                   | ARGUMENT default_value K_DESC_DELIMITER

   40 default_value: K_L_BRACKET K_DEFAULT_COLON DEFAULT_VALUE K_R_BRACKET
   41              | %empty

   42 bindings: bindings single_binding
   43         | single_binding

   44 single_binding: POSIX_OPTION
   45               | GNU_OPTION
   46               | POSIX_OPTION ARGUMENT
   47               | GNU_OPTION ARGUMENT
   48               | GNU_OPTION K_EQUAL_SIGN ARGUMENT