Grammar Analysis 1

Source: Internet
Author: User
Tags bitwise operators

<translation-unit>:: = {<external-declaration>}*

<external-declaration>:: = <function-definition>
| <declaration>

< translation Unit >:= {External declaration >} *//definition of a function

<declaration-specifier>:: = <storage-class-specifier>//definition of Class
| <type-specifier>
| <type-qualifier>

< storage class Descriptor >::= "Automatic"//automatic storage period, static storage period, external variable, definition type
| "Register"
| "Static"
| "extern"
| "typedef"

<type-specifier>:: = "void"//Type descriptor
| "Char"
| "Short"
| "Int"
| "Long"
| "Float"
| "Double"
| "Signed"
| "Unsigned"
| <struct-or-union-specifier>
| <enum-specifier>
| <typedef-name>

<struct-or-union-specifier>:: = <struct-or-union><identifier> "{" {<struct-declaration>}+ " }"//struct or union descriptor
| <struct-or-union> "{" {<struct-declaration>}+ "}"
| <struct-or-union> <identifier>

<struct-or-union>:: = "struct"//Structural Body
| "Union"

<struct-declaration>:: = {<specifier-qualifier>}*<struct-declarator-list>//Structure Declaration

<specifier-qualifier>:: = <type-specifier>//qualified type specifier
| <type-qualifier>

<struct-declarator-list>:: = <struct-declarator>//structStatement
| <struct-declarator-list> "," <struct-declarator>

<struct-declarator>:: = <declarator> //structStatement
| <declarator> ":" <constant-expression>
| ":" <constant-expression>

<declarator>:: = {<pointer>}? <direct-declarator>
<pointer>:: = "*" {<type-qualifier>}* {<pointer>}?//Pointers

<type-qualifier>:: = "Const"//constconstant, is aClanguage Key Words

| "Volatile"

<direct-declarator>:: = <identifier>//Direct declaration, identifier
| "(" <declarator> ")"
| <direct-declarator> "[" {<constant-expression>}? "]"
| <direct-declarator> "(" <parameter-type-list> ")"
| <direct-declarator> "(" {<identifier>}* ")"

<constant-expression>:: = <conditional-expression>//Conditional Expressions

<conditional-expression>:: = <logical-or-expression>//three-bit operators
| <logical-or-expression> "?" <expression> ":" <conditional-expression>

<logical-or-expression>:: = <logical-and-expression>//or
| <logical-or-expression "| |" <logical-and-expression>

<logical-and-expression>:: = <inclusive-or-expression>//with the
| <logical-and-expression "&&" <inclusive-or-expression>

<inclusive-or-expression>:: = <exclusive-or-expression>
| <inclusive-or-expression> "|" <exclusive-or-expression>

<exclusive-or-expression>:: = <and-expression> //XOR or
| <exclusive-or-expression> "^" <and-expression>

<and-expression>:: = <equality-expression>//with the
| <and-expression> "&" <equality-expression>

<equality-expression>:: = <relational-expression>
| <equality-expression> "= =" <relational-expression>//Take value
| <equality-expression> "! =" <relational-expression>//Not equal to

<relational-expression>:: = <shift-expression>
| <relational-expression> "<" <shift-expression>//less than
| <relational-expression> ">" <shift-expression>//Greater than
| <relational-expression> "<=" <shift-expression>//less than or equal
| <relational-expression> ">=" <shift-expression>//greater than or equal

<shift-expression>:: = <additive-expression>//Bitwise Operators
| <shift-expression> "<<" <additive-expression>
| <shift-expression> ">>" <additive-expression>

<multiplicative-expression>:: = <cast-expression> //' *,/,% '
| <multiplicative-expression> "*" <cast-expression>
| <multiplicative-expression> "/" <cast-expression>
| <multiplicative-expression> "%" <cast-expression>

<cast-expression>:: = <unary-expression>//Unary Operators
| "(" <type-name> ")" <cast-expression>

<unary-expression>:: = <postfix-expression>
| "+ +" <unary-expression>//Self-increment
| "--" <unary-expression>//Self-reduction
| <unary-operator> <cast-expression>
| "sizeof" <unary-expression>//Dynamically allocating space
| "sizeof" <type-name>

<postfix-expression>:: = <primary-expression>//suffix expression
| <postfix-expression> "[" <expression> "]"
| <postfix-expression> "(" {<assignment-expression>}* ")"
| <postfix-expression> "." <identifier>
| <postfix-expression>, <identifier>
| <postfix-expression> "+ +"
| <postfix-expression> "--"

<primary-expression>:: = <identifier> //prefix-expression
| <constant>
| <string>
| "(" <expression> ")"

<constant>:: = <integer-constant>//Integral type constant
| <character-constant>                           //Character Constants
| <floating-constant>//floating-point constants
| <enumeration-constant>//Enumeration Constants

<expression>:: = <assignment-expression>//an assignment expression
| <expression> "," <assignment-expression>

<assignment-expression>:: = <conditional-expression>//an assignment expression 
| <unary-expression> <assignment-operator><assignment-expression>

<assignment-operator>:: = "="//assignment operator
| "*="
| "/="
| "%="
| "+="
| "-="
| "<<="
| ">>="
| "&="
| "^="
| "|="
<!--[endif]-->

<unary-operator>:: = "&"         // operator
| "*"
| "+"
| "-"
| "~"
| "!"

<type-name>:: = {<specifier-qualifier>}+{<abstract-declarator>}?    // modifier

<parameter-type-list>:: = <parameter-list>         // parameter Type list
| <parameter-list> "," ...

<parameter-list>:: = <parameter-declaration>      // Parameter declaration
| <parameter-list> "," <PARAMETER-DECLARATION>

<parameter-declaration>: : = {<declaration-specifier>}+<declarator>        // declaration specifier
| {<declaration-specifier>}+ <abstract-declarator>
| {<declaration-specifier>}+

<abstract-declarator>:: = <pointer>      

| <pointer> <direct-abstract-declarator>//pointers, Direct summary description

| <direct-abstract-declarator>

<direct-abstract-declarator>:: = (<abstract-declarator>)//Direct declarator
| {<direct-abstract-declarator>}? "[" {<constant-expression>}? "]"
| {<direct-abstract-declarator>}? "(" {<parameter-type-list>|? ")"

<enum-specifier>:: = "enum" <identifier> "{" <enumerator-list> "}"//Enumeration Declarators
| "Enum" "{" <enumerator-list> "}"
| "Enum" <identifier>

<enumerator-list>:: = <enumerator>//Enumerator
| <enumerator-list> "," <enumerator>

<enumerator>:: = <identifier>//Enumeration Identifiers
| <identifier> "=" <constant-expression>

<typedef-name>:: = <identifier>//identifiers

<declaration>:: = {<declaration-specifier>}+{<init-declarator>}*//Initialize, declaration specifier 

<init-declarator>:: = <declarator>// Initialize declarator
| <declarator> "=" <initializer>

<initializer>:: = <assignment-expression>//Initialize
| "{" <initializer-list> "}"
| "{" <initializer-list> "," "}"

<initializer-list>:: = <initializer>//Initialize list
| <initializer-list> "," <initializer>

<compound-statement>:: = "{" {<declaration>}*{<statement>}* "}"//Compound Statement

<statement>:: = <labeled-statement>//Tag Statement

| <expression-statement>//An expression statement
| <compound-statement>//Compound Statement
| <selection-statement>//SELECT statement
| <iteration-statement>//Iteration Statements
| <jump-statement>//Jump Statement

<labeled-statement>:: = <identifier> ":" <statement>//Tag statement, identifier
| "Case" <constant-expression> ":" <statement>
| "Default" ":" <statement>

<expression-statement>:: = {<expression>}? ";"//An expression statement

<selection-statement>:: = "If" "(" <expression> ")" <statement>//SELECT statement
| "If" ("<expression>") "<statement> Else" <statement>//conditional Statements
| "Switch" ("<expression>") "<statement>//switch

<iteration-statement>:: = "while" ("<expression>") "<statement>//while , Do While, forLooping Statements
| "Do" <statement> "while" ("<expression>") "";
| "For" "(" {<expression>}? ";" {<expression>}? ";" {<expression>}? ")" <statement>

<jump-statement>:: = "goto" <identifier> ";"  //gotoJump Statement
| "Continue" ";"//continue to
| "Break" ";" //End
| "Return" {<expression>}? ";"//return

Grammar Analysis 1

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.