Elimination of the rule of C language grammar left recursion

Source: Internet
Author: User

<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>→< ' * ' >|< ' * ' pointers >

<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>→< identifier ><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

Elimination of the rule of C language grammar left recursion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.