C Language Grammar

Source: Internet
Author: User

< programs >→< external declarations >|< programs >< external declarations >

< external declarations >→< function definitions >|< declarations >

< function definition >→< type description >< declarator >< Compound statement >

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

< declarator >→< Pointer direct specifier >|< direct declarator >

< pointer >→< ' * ' >|< ' * ' pointer >

< direct declarator >< identifier >|< direct declarator ' ['] ' >|< direct declarator ' [' constant expression '] ' 〉|< identifier ' (' parameter table ') ' >|< identifier ' (') ' >|< Direct declarator ', ' identifier list >

< identifier list >:< identifier >|< identifier list > ', ' < identifier >

< constant expressions >→< conditional expressions >

< parameter list >→< parameter declaration >| parameter list ', ' < parameter declaration >

< parameter declarations >→< descriptor declarations >< identifiers >

< compound statement >→ ' {'} ' |   ' {' statement list '} ' | ' {' Declare statement list '} '

< declarations list >→< declarations > |< declarations list >< declarations >

< declarations >→< initialization declarations > |< initialization Declaration list > ', ' < initialization declaration >

< initialization declarations >→< Declarations > | < declaration > ' = ' < initialization program >

< initialization program >→< assignment expression > |< ' {' Initialization list '} ' > |< ' {' Initialization list ', '} ' >

< initialization list >→< Initialization Program > | < initialization list > ', ' < initialization program >

< statement list >→< Statement > | < statement list >< statements >

< statements >→< Compound statements > |< expression statements > |< conditional statements > |< loop statements > |< jump statements >

< expression statements >→< '; ' >| < expressions > '; '

< conditional statement >:<if ' (' expression ') statement > |< IF ' (' expression ') ' statement >< conditional statement >

< loop statement >→<while ' (' expression ') ' Statement > |< for ' (' expression statement expression statement ') ' Statement > | <for ' (' expression statement expression Statement expression ') ' Statement >

< jump statements >|< CONTINUE '; ' > |< break '; ' > | < RETURN '; ' > |< RETURN expression '; ' >

< expression >:< Assignment expression > |< expression > ', ' < Assignment expression >

< Assignment expressions >→< conditional expressions > |< unary expression Assignment operators >< Assignment Expressions >

< conditional expressions >→< logic or Representations > | < logic or expression > '? ' < expression > ': ' < conditional expression >

< logic or expression >→< logic and expression > |< logic or Expression > < or op-logical expressions >

< logic and expression >:< or expression >| < logical expressions > and < operations or expressions >

< or arithmetic expressions >→< xor expressions > |< or expression > ' | ' < XOR expressions >

< XOR expressions >:< expressions >|< xor expressions > ' ^ ' < and expressions >

< expressions >:< Equality expressions > |< and Expressions > ' & ' < equality expressions >

< equality expressions >:< Relational expressions > |< equality expressions equals expression of expressions > |< equality expressions are not equal to op-relational expressions >

< equality expressions >:< Relational expressions > |< equality expressions equals expression of expressions > |< equality expressions are not equal to op-relational expressions >

< shift expression >:< addition expression > |< shift Expression Left op addition expression > | < shift expression Right arithmetic addition expression >

< addition expression >:< multiplication expression > |< addition expression ' + ' multiplication expression > |< addition expression '-' multiplicative expression >

< multiplication expression >:< cast expression > |< multiplication expression ' * ' cast expression > |< multiplicative expression '/' cast expression > |< multiplicative expression '% ' cast expression >

< cast expression >:< unary expression > |< ' (' type name ') ' Cast expression >

< unary expression >:< suffix expression > |< inc operation unary expression > |< dec operation unary expression > |< unary operator >|  < unary expressions for struct variables > | < structure variable ' (' type name ') ' >

< postfix expression >:< basic expression >|< suffix expression ' [' expression '] ' >|< suffix expression ' (') >|< suffix expression ' (' parameter expression list ') ' >|< suffix expression '. ' identifier >|< suffix expression pointer operation identifier >| < postfix expressions Inc operations > |< suffix expressions Dec operations >

< basic expressions → identifiers > | < Constants > | < string Constants > | < ' (' expression ') ' >

< parameter expression list;: < Assignment expression > | < parameter expression list ', ' Assignment expression >

< unary operator;: < ' & ' > |  < ' * ' > | < ' + ' >| < '-' > | < ' ~ ' > | < '! ' >

< Assignment operators >→< ' = ' > | < multiplication distribution > | <div Distribution > | <mod Distribution > |  < addition allocation > | <sub Distribution > | < left Assignment > | < right Assignment > | < and distribution >| < XOR distribution > | < or distribution >

< storage class Descriptor >→< definition type > | < external variable >| < static > | < automatic > | < registers >

< struct or union specifier >:< struct or union identifier ' {' struct declaration list '} ' > |< struct or union ' {' struct declaration list '} ' > | < structure or Union identifier >

< structure or union >:< structure > | < Union >

< struct declaration list >:< struct declaration > | < struct declaration struct declaration list >

< struct declaration >:< Descriptor Qualifier List structure specifier '; ' Specifiers >→< type specifier specifier qualifier list >| < type specifiers > | < type qualifier specifier qualifier list >| < type qualifier >

< structure description list characters >→< struct declarations > | < struct descriptor list ', ' struct declaration >

< struct declarations >→:< declarations > | < ': ' Constant expression >| < declaration ': ' Constant expression >

< enum declaration >→< enum ' {' Enumerator list '} ' > | < enum identifier ' {' Enumerator list '} ' > | < enumeration identifiers >

< enumerator list >→< Enumerator > | < enumerator list ', ' Enumerator >

< enumerators >→< identifiers > | < identifier ' = ' constant expression >

< type qualifiers >→< Constants > | < volatile >

< type qualifier list >→< type qualifier > | < type qualifier list >< type qualifier >

< parameter type list >→< parameter list > | < parameter list ', ' ellipsis >

< parameter list >→:< declaration parameters > |< Parameter list ', ' Declaration parameters >

< type name >→< qualification description List characters > | < qualifier abstract description List characters >

< abstract specifiers >→< pointers > | < direct abstract specifiers > | < pointer direct abstract specifier >

< direct abstract specifier >→< ' (' abstract specifier ') ' >|  < ' ['] ' | ' [' constant expression '] ' >| < direct abstract specifier ' ['] ' >| < direct abstract specifier ' [' constant expression '] ' > | < ' (') ' >|< ' (' parameter Type list ') ' >|< direct abstract specifier ' (') ' >| < direct abstract specifier ' (' parameter Type list ') ' >

< labeled statement >→< identifier ': ' Statement > | <CASE constant expression ': ' Statement > | < DEFAULT ': ' Statement >

C Language Grammar

Related Article

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.