HPlogo HP C/HP-UX Reference Manual: Version A.05.55.02 > Appendix A Syntax Summary

Lexical Grammar

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

Tokens

token ::= keyword
        identifier
        constant
        string-literal
        operator
        punctuator

preprocessing-token ::=
        header-name
        identifier
        pp-number
        character-constant
        string-literal
        operator
        punctuator
        each non-white-space character cannot be one
of the above

Keywords

keyword ::= any word from the set:
        auto       extern    sizeof
        break      float     static
        case       for       struct
        char       goto      switch
        const      if        __thread (HP-UX 10.30 and later)
        continue   int       typedef
        default    long      union
        do         register  unsigned
        double     return    void
        else       short     volatile
        enum       signed    while

Identifiers

identifier ::= nondigit
             identifier nondigit
             identifier digit
             identifier dollar-sign

nondigit ::= any character from the set:
           _ a b c d e f g h i j k l m n o p
           q r s t u v w x y z A B C D E F G
           H I J K L M N O P Q R S T U V W X
           Y Z

digit ::= any character from the set:
        0 1 2 3 4 5 6 7 8 9

dollar-sign ::= the $ character

Constants

constant ::=
       floating-constant
       integer-constant
       enumeration-constant
       character-constant

floating-constant ::=
       fractional-constant [exponent-part] [floating-suffix]
       digit-sequence exponent-part [floating-suffix]

fractional-constant ::=
       [digit-sequence] . digit-sequence
       digit-sequence .

exponent-part ::=
    e [sign] digit-sequence
    E [sign] digit-sequence

sign ::=
    +
    -

digit-sequence ::=
    digit
    digit-sequence digit

floating-suffix ::=
    f  l  F  L

integer-constant ::=
    decimal-constant [integer-suffix]
    octal-constant [integer-suffix]
    hexadecimal-constant [integer-suffix]

decimal-constant ::=
    nonzero-digit
    decimal-constant digit

octal-constant ::=
    0
    octal-constant octal-digit

hexadecimal-constant ::=
    0x hexadecimal-digit
    0X hexadecimal-digit
    hexadecimal-constant hexadecimal-digit

nonzero-digit ::= any character from the set:
    1  2  3  4  5  6  7  8  9

octal-digit ::= any character from the set
    0  1  2  3  4  5  6  7

hexadecimal-digit ::= any character from the set
    0  1  2  3  4  5  6  7  8  9
    a  b  c  d  e  f
    A  B  C  D  E  F


integer-suffix ::=
    unsigned-suffix [long-suffix]
    length-suffix [unsigned-suffix]

unsigned-suffix ::=
    u  U

length-suffix ::=
    long-suffix
    long-long-suffix

long-suffix ::= any character from the set
    l  L

long-long-suffix ::= any character from the set
    ll LL Ll lL

enumeration-constant ::= identifier

character-constant ::=
    'c-char-sequence'
    L'c-char-sequence'

c-char-sequence ::=
    c-char
    c-char-sequence c-char

c-char ::=
    any character in the source character set except
       the single quote ('), backslash (\), or new-line character
    escape-sequence

escape-sequence ::=
    simple-escape-sequence
    octal-escape-sequence
    hexadecimal-escape-sequence

simple-escape-sequence ::=
    \'   \"    \?  \\   \ddd   \xdd
    \a   \b    \f   \n   \r   \t   \v

octal-escape-sequence ::=
    \ octal-digit
    \ octal-digit octal-digit
    \ octal-digit octal-digit octal-digit

hexadecimal-escape-sequence ::=
    \x hexadecimal-digit
    hexadecimal-escape-sequence hexadecimal-digit

String Literals

string-literal ::=
    "[s-char-sequence]"
    L"[s-char-sequence]"

s-char-sequence ::=
    s-char
    s-char-sequence s-char

s-char ::=
    any character in the source character set except
           the double-quote (") , backslash (\), or new-line
    character escape-sequence

Operators

operator ::= One selected from:
    [    ]    (    )    .    ->
    ++   --   &    *    +    -    ~   !   sizeof
    /    %    <<   >>   <    >    <=    >=   ==   !=   ^    |
   &&    ||  ?    :
    =    *=   /=   %=   +=   -=  <<=   >>=   &=  ^=   |=
    ,    #    ##

Punctuators

punctuator ::=  One selected from:
    [   ]   (   )   {   }   *   ,   :   =   ;   ...   #

Header Names

header-name ::=
         <h-char-sequence>
         "q-char-sequence"

h-char-sequence ::=
         h-char
         h-char-sequence h-char

h-char ::=
         any character in the source character set except
             the newline character and >

q-char-sequence ::=
         q-char
         q-char-sequence q-char

q-char ::=
         any character in the source character set except
             the newline character and "

Preprocessing Numbers

pp-number ::=
         digit
         . digit
         pp-number digit
         pp-number nondigit
         pp-number e sign
         pp-number E sign
         pp-number .

© Hewlett-Packard Development Company, L.P.