SHARE
TWEET

Untitled

a guest Mar 1st, 2019 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # FILE:         c.cfg
  2. # PURPOSE:      The Grammar for Standard C with _opt factored out,
  3. #               and the oversight for enumeration-constant corrected.
  4. #
  5. # LANGUAGE:     C
  6. #
  7. # TRANSCRIBED:  McKeeman @ WangInst     1986
  8. # MODIFIED:     {0} McKeeman -- 89.08.15 -- original
  9. #               {1} Aurenz   -- 89.09.07 -- rc parser complete
  10. #               {2} Aki      -- 92.01.06 -- support awk processing
  11. #               {3} McKeeman -- 92.02.25 -- restore ANSI details
  12. #               {4} McKeeman -- 93.01.08 -- removed : after lhs
  13. #
  14. #Input format for c.cfg:
  15. #
  16. #  1) comments must have a '#' in column 1,
  17. #     or be an entirely empty line
  18. #
  19. #  2) The format of a rule is:
  20. #       lhs
  21. #           rhs1
  22. #           rhs2
  23. #           ...
  24. #           rhsN
  25. #
  26. #     The left hand side must start with a non-blank in column 1.
  27. #
  28. #     The right hand side(s) must start with a blank in column 1.
  29. #     The r.h.s. must be on one line.
  30. #     Blanks must be used to separate tokens in the r.h.s.
  31. #
  32. #  3) An empty rhs is specified with the predefined keyword:
  33. #        _E_M_P_T_Y_R_U_L_E_
  34. #     as the only token on the line.  There are no examples in C.
  35. #
  36. #[begin example]
  37. #
  38. # ,---- column 1
  39. # |
  40. # v
  41. #
  42. # # rule xxx
  43. # xxx
  44. #     yyy + yyy
  45. #     zzz xxx
  46. #
  47. # # rule yyy (1st alternative is empty)
  48. # yyy
  49. #     _E_M_P_T_Y_R_U_L_E_
  50. #     yyy - xxx
  51. #
  52. # # rule zzz (empty)
  53. # zzz
  54. #     _E_M_P_T_Y_R_U_L_E_
  55. #
  56. #[end example]
  57. #
  58.  
  59.  
  60. #
  61. # C expression rules
  62. #
  63.  
  64. primary-expression
  65.     identifier
  66.     constant
  67.     string-literal
  68.     ( expression )
  69.  
  70. postfix-expression
  71.     primary-expression
  72.     postfix-expression [ expression ]
  73.     postfix-expression ( )
  74.     postfix-expression ( argument-expression-list )
  75.     postfix-expression . identifier
  76.     postfix-expression -> identifier
  77.     postfix-expression ++
  78.     postfix-expression --
  79.  
  80. argument-expression-list
  81.     assignment-expression
  82.     argument-expression-list , assignment-expression
  83.  
  84. unary-expression
  85.     postfix-expression
  86.     ++ unary-expression
  87.     -- unary-expression
  88.     unary-operator cast-expression
  89.     sizeof unary-expression
  90.     sizeof ( type-name )
  91.  
  92. unary-operator
  93.     &
  94.     *
  95.     +
  96.     -
  97.     ~
  98.     !
  99.  
  100. cast-expression
  101.     unary-expression
  102.     ( type-name ) cast-expression
  103.  
  104. multiplicative-expression
  105.     cast-expression
  106.     multiplicative-expression * cast-expression
  107.     multiplicative-expression / cast-expression
  108.     multiplicative-expression % cast-expression
  109.  
  110. additive-expression
  111.     multiplicative-expression
  112.     additive-expression + multiplicative-expression
  113.     additive-expression - multiplicative-expression
  114.  
  115. shift-expression
  116.     additive-expression
  117.     shift-expression << additive-expression
  118.    shift-expression >> additive-expression
  119.  
  120. relational-expression
  121.     shift-expression
  122.     relational-expression < shift-expression
  123.    relational-expression > shift-expression
  124.     relational-expression <= shift-expression
  125.    relational-expression >= shift-expression
  126.  
  127. equality-expression
  128.     relational-expression
  129.     equality-expression == relational-expression
  130.     equality-expression != relational-expression
  131.  
  132. AND-expression
  133.     equality-expression
  134.     AND-expression & equality-expression
  135.  
  136. exclusive-OR-expression
  137.     AND-expression
  138.     exclusive-OR-expression ^ AND-expression
  139.  
  140. inclusive-OR-expression
  141.     exclusive-OR-expression
  142.     inclusive-OR-expression | exclusive-OR-expression
  143.  
  144. logical-AND-expression
  145.     inclusive-OR-expression
  146.     logical-AND-expression && inclusive-OR-expression
  147.  
  148. logical-OR-expression
  149.     logical-AND-expression
  150.     logical-OR-expression || logical-AND-expression
  151.  
  152. conditional-expression
  153.     logical-OR-expression
  154.     logical-OR-expression ? expression : conditional-expression
  155.  
  156. assignment-expression
  157.     conditional-expression
  158.     unary-expression assignment-operator assignment-expression
  159.  
  160. assignment-operator
  161.     =
  162.     *=
  163.     /=
  164.     %=
  165.     +=
  166.     -=
  167.     <<=
  168.    >>=
  169.     &=
  170.     ^=
  171.     |=
  172.  
  173. expression
  174.     assignment-expression
  175.     expression , assignment-expression
  176.  
  177. constant-expression
  178.     conditional-expression
  179.  
  180. #
  181. # C declaration rules
  182. #
  183.  
  184. declaration
  185.     declaration-specifiers ;
  186.     declaration-specifiers init-declarator-list ;
  187.  
  188. declaration-specifiers
  189.     storage-class-specifier
  190.     type-specifier
  191.     type-qualifier
  192.     storage-class-specifier declaration-specifiers
  193.     type-specifier          declaration-specifiers
  194.     type-qualifier          declaration-specifiers
  195.  
  196. init-declarator-list
  197.     init-declarator
  198.     init-declarator-list , init-declarator
  199.  
  200. init-declarator
  201.     declarator
  202.     declarator = initializer
  203.  
  204. storage-class-specifier
  205.     typedef
  206.     extern
  207.     static
  208.     auto
  209.     register
  210.  
  211. type-specifier
  212.     void
  213.     char
  214.     short
  215.     int
  216.     long
  217.     float
  218.     double
  219.     signed
  220.     unsigned
  221.     struct-or-union-specifier
  222.     enum-specifier
  223.     typedef-name
  224.  
  225. struct-or-union-specifier
  226.     struct-or-union { struct-declaration-list }
  227.     struct-or-union identifier { struct-declaration-list }
  228.     struct-or-union identifier
  229.  
  230. struct-or-union
  231.     struct
  232.     union
  233.  
  234. struct-declaration-list
  235.     struct-declaration
  236.     struct-declaration-list struct-declaration
  237.  
  238. struct-declaration
  239.     specifier-qualifier-list struct-declarator-list ;
  240.  
  241. specifier-qualifier-list
  242.     type-specifier
  243.     type-qualifier
  244.     type-specifier specifier-qualifier-list
  245.     type-qualifier specifier-qualifier-list
  246.  
  247. struct-declarator-list
  248.     struct-declarator
  249.     struct-declarator-list , struct-declarator
  250.  
  251. struct-declarator
  252.     declarator
  253.      constant-expression
  254.     declarator  constant-expression
  255.  
  256. enum-specifier
  257.     enum { enumerator-list }
  258.     enum identifier { enumerator-list }
  259.     enum identifier
  260.  
  261. enumerator-list
  262.     enumerator
  263.     enumerator-list , enumerator
  264.  
  265. enumerator
  266.     enumeration-constant
  267.     enumeration-constant = constant-expression
  268.  
  269. enumeration-constant
  270.     identifier
  271.  
  272. type-qualifier
  273.     const
  274.     volatile
  275.  
  276. declarator
  277.     direct-declarator
  278.     pointer direct-declarator
  279.  
  280. direct-declarator
  281.     identifier
  282.     ( declarator )
  283.     direct-declarator [ ]
  284.     direct-declarator [ constant-expression ]
  285.     direct-declarator ( )
  286.     direct-declarator ( parameter-type-list )
  287.     direct-declarator ( identifier-list )
  288.  
  289. pointer
  290.      *
  291.      * pointer
  292.      * type-qualifier-list
  293.      * type-qualifier-list pointer
  294.  
  295. type-qualifier-list
  296.     type-qualifier
  297.     type-qualifier-list type-qualifier
  298.  
  299. parameter-type-list
  300.     parameter-list
  301.     parameter-list , ...
  302.  
  303. parameter-list
  304.     parameter-declaration
  305.     parameter-list , parameter-declaration
  306.  
  307. parameter-declaration
  308.     declaration-specifiers declarator
  309.     declaration-specifiers
  310.     declaration-specifiers abstract-declarator
  311.  
  312. identifier-list
  313.     identifier
  314.     identifier-list , identifier
  315.  
  316. type-name
  317.     specifier-qualifier-list
  318.     specifier-qualifier-list abstract-declarator
  319.  
  320. abstract-declarator
  321.     pointer
  322.     direct-abstract-declarator
  323.     pointer direct-abstract-declarator
  324.  
  325. direct-abstract-declarator
  326.     ( abstract-declarator )
  327.     [ ]
  328.     [ constant-expression ]
  329.     ( )
  330.     ( parameter-type-list )
  331.     direct-abstract-declarator [ ]
  332.     direct-abstract-declarator [ constant-expression ]
  333.     direct-abstract-declarator ( )
  334.     direct-abstract-declarator ( parameter-type-list )
  335.  
  336. typedef-name
  337.     identifier
  338.  
  339. initializer
  340.     assignment-expression
  341.     { initializer-list }
  342.     { initializer-list , }
  343.  
  344. initializer-list
  345.     initializer
  346.     initializer-list , initializer
  347.  
  348. #
  349. # C statement rules
  350. #
  351.  
  352. statement
  353.     labeled-statement
  354.     compound-statement
  355.     expression-statement
  356.     selection-statement
  357.     iteration-statement
  358.     jump-statement
  359.  
  360. labeled-statement
  361.     identifier : statement
  362.     case constant-expression : statement
  363.     default : statement
  364.  
  365. compound-statement
  366.     { }
  367.     { declaration-list }
  368.     { statement-list }
  369.     { declaration-list statement-list }
  370.  
  371. declaration-list
  372.     declaration
  373.     declaration-list declaration
  374.  
  375. statement-list
  376.     statement
  377.     statement-list statement
  378.  
  379. expression-statement
  380.     ;
  381.     expression ;
  382.  
  383. selection-statement
  384.     if ( expression ) statement
  385.     if ( expression ) statement else statement
  386.     switch ( expression ) statement
  387.  
  388. iteration-statement
  389.     while ( expression ) statement
  390.     do statement while ( expression ) ;
  391.     for (            ;            ;            ) statement
  392.     for (            ;            ; expression ) statement
  393.     for (            ; expression ;            ) statement
  394.     for (            ; expression ; expression ) statement
  395.     for ( expression ;            ;            ) statement
  396.     for ( expression ;            ; expression ) statement
  397.     for ( expression ; expression ;            ) statement
  398.     for ( expression ; expression ; expression ) statement
  399.  
  400. jump-statement
  401.     goto identifier ;
  402.     continue ;
  403.     break ;
  404.     return ;
  405.     return expression ;
  406.  
  407. translation-unit
  408.     external-declaration
  409.     translation-unit external-declaration
  410.  
  411. external-declaration
  412.     function-definition
  413.     declaration
  414.  
  415. function-definition
  416.                            declarator                  compound-statement
  417.     declaration-specifiers declarator                  compound-statement
  418.                            declarator declaration-list compound-statement
  419.     declaration-specifiers declarator declaration-list compound-statement
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top