Thread: ANSI C identifiers

  1. #1
    Registered User
    Join Date
    Sep 2002

    Unhappy ANSI C identifiers

    I have been trying to find a list of regular expressions that define identifiers in ANSI C but have gotten nowhere, can anyone give me a list????? please

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002


    Well there are 25 reserved words in C. Those as well as an operator precedence chart can be found in pretty much any C text/reference book. Is this what you mean?

    Mr C

  3. #3
    Join Date
    Aug 2001
    If you mean bnf you can find that in a draft of the c standard.

    Under 6.4 it defines what a token is.
    There's actually a bit more than 25 keywords but they
    added a few to the c99 draft.

    You read these rules like this
    identifier: |
    identifier-nondigit ||
    identifier identifier-nondigit ||
    identifier digit

    identifier is defined to be a identifier-nondigit or
    identifier followed by a identifier-nondigit
    or a identifier followed by a digit.

    These definitions are recursive. Practictice generating
    some common identifiers in your program like this.
    identifier digit
    identifier identifier-nondigit digit
    identifier-nondigit identifier-nondigit digit
    a identifier-nondigit digit
    ab digit

    It is clear from the definition you cannot have
    identifiers having the first charecter as a number.

    The lexical stuft such as identifiers are easy to read. The
    whole c syntax is defined this way--some of it is a bit more

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to know if my code is ANSI strict ?
    By jabka in forum C Programming
    Replies: 1
    Last Post: 10-19-2007, 07:32 AM
  2. ANSI C Reference
    By Stack Overflow in forum A Brief History of
    Replies: 1
    Last Post: 03-09-2005, 10:08 PM
  3. how closely does 2003 follow ANSI?
    By krygen in forum C++ Programming
    Replies: 7
    Last Post: 09-22-2004, 06:48 PM
  4. sigaction() and ANSI C
    By awoodland in forum Linux Programming
    Replies: 4
    Last Post: 04-25-2004, 01:48 AM
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM