码迷,mamicode.com
首页 > 编程语言 > 详细

C语言 文法规则之消除左递归

时间:2016-12-03 01:31:43      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:ora   ram   word   val   oat   ble   class   标识符   文法   

<program>→<external declarations>(<program>|~)

<external declarations>→<function definition>|<declaration>

<function definition>→<type declaration><declarator><consistent statement>

<type declaration>→<void>|<char>|<int>|<float>

<declarator>→<indicator declarator>|<direct declarator>

<indicator>→<‘*‘>|< ‘*‘ 指针>

<direct declarator>→<ID>|<’[‘ ‘]’>|<‘[‘constexpr‘]‘>|<parameter>|<(‘ ‘)>|<ID list>

<compound statement>→<‘{‘ ‘}‘>|<statement list>|<declaration list>

<declaration list>→<declaration>|<declaration list>

<ID list>→<ID>(<ID list>|~)


<constexpr>→<conditional expression>

<parameter table>→<parameter declaration> (<parameter table>|~)


<declaration>→<declaration>|<declaration table declarated>

<initialise>→<assignment expression>|<“{}”“initialise table”>

<initialise table>→<initialise>|<‘initialise table‘initialise>

<statement list>→<statement>(<statement list>|~)

<statement>→<compound statement>|<expression statement>|<choose statement>|<iteration statement>|<skip statement>

<choose statement>→<if>|<IF (“expression”)ELSE expression declaration>

<iteration statement>→< WHILE >|< FOR >|< FOR ><statement>

<skip statement>→< CONTINUE >|< BREAK >< RETURN >< RETURN ><statement>

<unary operator>→ ‘&‘| ‘*‘| ‘+‘| ‘-‘| ‘~‘| ‘!‘

<storage class declarator>→< TYPEDEF >|< EXTERN >|< STATIC >|< AUTO >|< REGISTER >

<struct or unite declarator>→<struct or unite declarator><struct declaration table>
|<struct or unite><struct declaration table>|<struct or unite><ID>
<struct or unite declarator>→<struct or unite><ID><struct or unite><struct declaration table> <struct or unite declarator>‘
<struct or unite declarator>‘→<struct declaration table> <struct or unite declarator>‘|~

<struct or unite>→< STRUCT >|< UNION >


<struct declaration table>→<struct declaration> (<struct declaration table>|~)


<struct declaration>→<declarator qualifier table><struct declarator >

<declarator qualifier table>→<type declarator><declarator qualifier table>|<declarator qualifier table>


<struct declarator table>→<struct declaration> (<struct declaration table>|~)


<struct declaration>→<declaration>|<constant expression>|<constant expression><declaration>

<enumeration declaration>→<enumeration table>|<enumeration ID><enumeration table>|<enumeration ID>


<enumeration ID>→<enumeration>(<enumeration ID>|~)

<enumeration>→<标识符><ID>|constant expression><ID>

<function definition> →<type declaration><function name><parameter table>
<function name>→<ID>
<compound statement><parameter table>→<type declaration><variable name>
<compound statement>→<variable>|<statement>
<statement>→<expression statement>|<choose statement>|<circulate statement>|<skip statement>
<expression statement>→<assignment expression>|<relation expression>|
<logic expression>
<assignment expression>→ = | += | =+ | -= | =-
<relation expression> →| < | 〉=| <=
<logic expression>→ + | - | * | /
<choose statement>→ if else| switch
<circulate statement>→ for|while|do while
<skip statement>→ return|break|continue
<variable> → <type>丨<variable name>丨<variable values>
<type declaration> —> int丨char丨double丨float丨long
<variable name → S
S —> A|SB
A —> a|b|c|……y|z
B —> 0|1|2|3|4|5|6|7|8|9
<variable values> —> <word>丨<number>
<ID> → S
S —> a|b|c|……y|z|S
<word> →a|b|c|……y|z
<<number>→ S
A —> 1|2|3|4|5|6|7|8|9
S —> A|SA|SA0

C语言 文法规则之消除左递归

标签:ora   ram   word   val   oat   ble   class   标识符   文法   

原文地址:http://www.cnblogs.com/dami666/p/6127619.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!