C Language Grammar

Source: Internet
Author: User

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

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

< function definitions >→< type descriptions >< declarations >< Compound statements >

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

< declaration >→< Pointer Direct specifier >|< direct specifier >

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

< direct specifier >→< identifier >|< direct specifier ' [' '] ' >|< direct specifier ' [' constant expression '] ' > |< identifier ' (' argument list ') ' >|< identifier >< ' (') ' >>|< direct specifier >< ', ' >< identifier list >

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

< constant expressions >→< conditional expressions >

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

< parameter declarations >→< declaration specifiers >< Identifiers >

< compound statement >→< ' {' >< '} ' >|< ' {' >< statement list >< '} ' >|< ' {' >< Declaration list >< Statement list >< '} ' >

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

< declaration >→< Initialization declaration >|< Initialization Declaration List >< ', ' >< initialization declaration >

< initialization declaration >→< declaration >|< Declaration >< ' = ' >< initialization program >

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

< initialization program List >→< initialization program >|< initializer list >< ', ' >< initialization program >

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

< statements >→< Compound statements >|< expression Statements >|< SELECT statements >|< loop statements >|< jump statements >

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

< SELECT statement >→<:><if>< ' (' >< expression >< ') ' >< statement >|<if>< ' (' >< expression > < ') ' >< statements ><else>< statements >

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

< jump statements >→CONTINUE< '; ' >| Break < '; ' >| RETURN < '; ' >| RETURN < expressions > < '; ' >

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

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

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

< logic or expression >→< logic and expression > |< logic or expression or operation >< logical Expressions >

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

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

< XOR expressions >:< and Expressions > | < xor expression >< ' ^ ' >< with expression >

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

< equality expressions >:< Relational expressions > |< equality expressions equals an expression of an operation relationship > | < equality expression is not equal to an expression of an operation relationship >

< relationship expressions >:< Shift Expressions > | < relationship expression >< ' < ' >< shift expression >|< relational expression >< ' > ' >< shift expression > |< relational expression less than equals op shift expression > | < relationship expression is greater than or equal to an op shift expression >

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

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

< multiplication expressions >:< cast Expressions > | < multiplication expression >< ' * ' >< cast expression > | < multiplication expressions >< '/' >< cast expressions >| < multiplication expression >< '% ' >< cast expression >

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

< unary expressions >:< Postfix Expressions > | <inc operation unary expression > |< dec operation unary expression > |< unary operator the expression > | The unary expression of < structure variables >| < structure variables >< ' (' >< type name >< ') ' >

< postfix expressions >:< Basic Expressions > | < postfix expression >< ' [' >< expression >< '] ' > |< suffix Expression >< ' (' >< ') ' > | < suffix expression >< ' (' >< parameter expression list >< ') ' > | < suffix expression >< '. ' >< identifier >| < suffix expression pointer operation identifier > |< suffix expression inc operation > |< suffix expression Dec operation >

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

< parameter expression list >:< assignment expression >| < parameter expression list >< ', ' >< assignment expression >

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

< assignment operator >→< ' = ' > |< multiplication Assignment > | <div Assignment > |< mod Assignment > | < addition allocation > | < sub Assignment > |< left Assignment >| < right assignment and assignment >|< XOR assignment >|< or Assignment >

< storage class Specifiers >→< defining types > |< external variables > |< static >|< auto > | < registers >

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

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

< struct declaration list >:< struct declaration > |< struct list declaring struct body declaration >

< struct declaration >:< Descriptor Qualifier List structure specifier >< '; ' >

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

< structure description list characters >→< struct declaration > |< Structure Description list characters >< ', ' >< struct declaration >

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

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

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

< enumerator enumerator >→< identifiers >|< identifiers >< ' = ' >< 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 >

< 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 statements >→< Identifiers >< ':>< ' statements > | <CASE constant Expression >< ': ' >< statement > | < default>< ': ' >< statements >

C Language Grammar

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.