ANSI C identifiers

This is a discussion on ANSI C identifiers within the C Programming forums, part of the General Programming Boards category; I have been trying to find a list of regular expressions that define identifiers in ANSI C but have gotten ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    1

    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
    Posts
    511

    Question

    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
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    If you mean bnf you can find that in a draft of the c standard.
    http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm

    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
    identifier digit
    identifier identifier-nondigit digit
    identifier-nondigit identifier-nondigit digit
    a identifier-nondigit digit
    ab digit
    ab4

    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
    complex.

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 Cprogramming.com
    Replies: 1
    Last Post: 03-09-2005, 09:08 PM
  3. how closely does vc++.net 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
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21