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