.Open Syntax of The C Programming Language . Cross-Refferences ASCII::=http://www.csci.csusb.edu/dick/samples/comp.text.ASCII.html Used_in The definition of C++ .See http://www.csci.csusb.edu/dick/samples/c++.syntax.html Used_in The definition of Java .See http://www.csci.csusb.edu/dick/samples/java.syntax.html . Notation This uses my XBNF Extended BNF Notation where "|" indicates "or", "(...)" indicates priority. For more information see .See http://www/dick/maths/intro_ebnf.html The following abbreviations are also used: .Box O(_) ::= 0 or 1 occurrences, N(_) ::= 1 or more occurrence L(_) ::= a comma separated list #(_) ::= 0 or more occurrences. S(E,Op)::=$serial_operator_expression(E, Op) serial_operator_expression(E,Op)::= E #(Op E). .Close.Box It also uses the following shorthand . Lexemes identifier::=$nondigit #($nondigit | $digit), nondigit::="_" | "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F" | "g" | "G" | "h" | "H" | "i" | "I" | "j" | "J" | "k" | "K" | "l" | "L" | "m" | "M" | "n" | "N" | "o" | "O" | "p" | "P" | "q" | "Q" | "r" | "R" | "s" | "S" | "t" | "T" | "u" | "U" | "v" | "V" | "w" | "W" | "x" | "X" | "y" | "Y" | "z" | "Z", digit::="0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", punctuator::="[" | "]" | "(" | ")" | "{" | "}" | "*" | "," | ":" | "=" | ";" | "..." | "#", operator::="[" | "]" | "(" | ")" | "." | "+>" | "++" | "--" | "&" | "*" | "+" | "-" | "~" | "!" | "sizeof" | "/" | "%" | "<<" | ">>" | "<" | ">" | "<=" | ">=" | "==" | "!=" | "^" | "|" | "&&" | "||" | "?" | ":" | "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "^=" | "||=" | "," | "#" | "##", integer_suffix::=#($unsigned_suffix) | #($long_suffix), unsigned_suffix::="u" | "U", long_suffix::="l" | "L", sign::="+" | "-", octal_constant::="0" #($octal_digit), octal_digit::="0" | "1" | "2" | "3" | "4" | "5" | "6" | "7", hex_constant::=("0x" | "0X") ($hex_digit), hex_digit::="0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F", decimal_constant::=$non_zero_digit #($digit), non_zero_digit::="1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", integer_constant::=($decimal_constant | $octal_constant | $hex_constant) | $integer_suffix, float_suffix::="f" | "l" | "F" | "L", fraction::=#$digit "." $digit #$digit, exponent_part::=("e" | "E") $sign #($digit), float_constant::=$fraction ($exponent_part|) ($float_suffix|)|($decimal_constant ($exponent_part|) $float_suffix, enumeration_constant::=$identifier, char_constant::=$char~($double_quote|$eoln|$backslash)| $escape_sequence, escape_sequence::=$backslash ($char | "0" #$octal_digit |"0x"#$hexadecimal_digit), character_constant::="'" $char_constant"'" , constant :=::=$float_constant | $integer_constant | $enumeration_constant | $character_constant, string__char::=$char~($double_quote|$eoln|$backslash)| $escape_sequence, string_literal::=$double_quote #($string_char) $double_quote, . Expressions primary_expression::= $variable | $constant | $string_literal | "(" $expression ")", variable::= $identifier & `$declared $and $in $scope $of $declaration`. argument_list::=$List($assignment_expression), post_fix::="++" | "--", post_fix_expression::=($primary_expression) #($post_fix), unary_operator::="&" | "*" | "+" | "-" | "!" | "-", pre_fix::="++" | "--" | "sizeof", unary_expression::=#($pre-$fix) $post_fix_expression | $unary_operator $cast_expression | "sizeof" "(" $type_name")", cast_expression::=#($type_name) $unary_expression. This implies that casts are done after doing post-fix operations.. multiplicative_expression::=$S($cast_expression, $multiplicative_operator). .See serial_operator_expression The rule above means that 'casts' are done before multiplication and division, and that multiplication and division are done from left to right. multiplicative_operator::="*" | "%" | "/", additive_expression::=$S($multiplicative_expression, $additive_operator). This means that addition and subtraction occurs after multiplication and from left to right. additive_operator::="+" | "-", shift_expression::=$S($additive_expression, $shift_operator), shift_operator::=">>" | "<<", relational_expression::= $S($shift_expression, $relational_operator), relational_operator::="<" | ">" | "<=" | ">=", equality_expression::=$S($relational_expression, $equality_operator), equality_operator::="==" | "!=", AND_expression::=$S($equality_expression, $and_operator), and_operator::="&", This operator takes each bit in the value of its arguments in turn to calculate the bit in the answer. A bit is 1 if and only if both arguments have bits in that palce that are 1. XOR_ $expression::=$S($AND_expression, $XOR_operator), XOR_operator::="^", XOR is short for eXclusive-OR. The n'th bit in the value is 1 precisly when the n'th bits in the two arguments are different. OR_expression::=$S($XOR_expression, $OR_operator), OR_operator::="|", This operator takes each bit in the value of its arguments in turn to calculate the bit in the answer. The n'th bit is 1 if either n'th bits is 1. logical_AND_expression::=$S($OR_expression, $logical_AND_operator), logical_AND_operator::="&&", A&&B is true precisely when both A and B evaluate to be true. logical_OR_expression::=$S($logical_AND_expression, $logical_OR_operator), logical_OR_operator::="||", A|B is true if A is evaluates to be true, or when A is false and B evaluates to be true. conditional_expression::=$logical_OR_expression | $logical_OR_expression "?" $expression ":" $conditional_expression, assignment_expression::=$S($unary_expression, $assignment_operator), assignment_operator::="=" | "*=" | "/=" | "%=" | "+=" | "<<=" | ">>=" | "&=" | "^=" | "|=", expression::=$List($assignment_expression ), constant_expression::=$conditional_expression, . Declarations storage_class::="typedef" | "extern" | "static" | "auto" | "register", typedef_name::=$identifier, type_specifier::="void" | "char" | "short" | "int" | "long" | "float" | "double" | "signed" | "unsigned" | $struct_union_specifier | $enumeration_specifier | $typedef_name, type-$qualifier::="const" | "volatile", initializer::=$assignment_expression | $initializer_list, initializer_list::=$List($initializer), declarator_initialized::=$declarator ("=" $initializer), declarator_list::=$List($declarator_initialized), declaration_specifier::=($storage_class | $type_specifier | $type_qualifier), declaration::=$declaration_specifier | $declarator_list, structure_declarator::=$declarator | $declarator ":" $constant_expression, structure_declarator_list::=$List($structure_declarator), structure_declaration::=($type_specifier | $type_qualifier) $structure_declarator_list ";" , struct_union_specifier::=$struct_union $identifier | $struct_union $identifier "{"$structure_declarator_list "}", struct_union::=( "struct" | "union" ), enumeration_value::=$enumeration_constant ("=" $constant_expression|) enumeration_list::=$List($enumeration_value ), enumeration_specifier::=$enumeration_identifier | "enum" $identifier "{"$enumeration_list"}", function_definition::=$declaration_specifier $declarator | $declaration_list | $compound_statement, parameter_declaration::=#$declaration_specifier $declarator | $abstract_declarator, parameter_list::=$List($parameter_declaration) (",..."|), pointer::=#( "*" | #$type_qualifier), declarator::=$pointer | $direct_declarator, post_declarator::="["$constant_expression"]" | "("$parameter_list")" | "("$identifier_list")" direct_declarator::=$identifier | "("$declarator")" | $direct_declarator $Post_declarator, abstract_declarator::=$pointer | $pointer $direct_abstract_declarator, direct_abstract_declarator::=($abstract_declarator $direct_abstract_declarator) ("<" $constant_expression) | ($parameter_list), .Open Statements jump_statement::="goto" $identifier";" | "continue" ";" | "break;" | "return" $expression ";", loop::=$iteration_statement. iteration_statement::="while" "("$expression")" $statement | "do" $statement "while" "("$expression")" ";" | "for" "("$expression ";" $expression ";" $expression")" $statement, selection_statement::="if ("$expression")" $statement | "if" "("$expression")" $statement "else" $statement | "switch" "("$expression")" $statement, expression_statement::= $expression ";", labeled_statement::=$identifier ":" $statement | "case" $constant_expression ":" $statement | "default" ":" $statement, compound_statement::=$block | "{" #$statement "}", block::="{" $declaration #$declaration #$statement "}", statement::=$labeled_statement | $compound_statement | $expression_statement | $selection_statement | $iteration_statement | $jump_statement .Close Statements . Pre-Processor Commands preprocess_token::=$identifier | $constant | $string_literal | $operator | $punctuator | `$each $Non-$white $space $not $one $of $the $previous`, header_char::=`$any $character $except $new_line | $and | >`, header_name::=#($header_char), new_line::=$new_line $character, Left_paren::=`$left $parenthesis $with $no $white $space $before $it`, control_line::="#include" (#($preprocess_token | $header_name) $new_line | "#define" $identifier #($preprocess_token) $new_line | "#define" $identifier $left_paren $identifier_list #($preprocess_token) $new_line, | "#undef" $identifier $new_line | "#line" $preprocess_token $new_line | "#error" $preprocess_token $new_line | "#pragma" $preprocess_token $new_line | "#"$new_line, endif_line::="#endif" $new_line, elif_group::="#elif" $constant_expression $new_line $pp_group, else_group::="#else" $new_line $pp_group, if_group::=("#if" $constant_expression | "#ifdef" $identifier | "#ifndef" $identifier) $new_line $pp_group, if_part::=$if_group #($elif_group) $else_group $endif_line, pp_part::=#$preprocess_token $new_line | $if_part | $control_line, pp_group::=#($pp_part), .Close