[Tutor] identifier token parsing [was Re: (no subject)]
w chun
wescpy at gmail.com
Fri Dec 30 07:04:48 CET 2005
> hello everyone. i was looking at python docs and i came across this
>
> letter ::=
> lowercase | uppercase
>
> what does ::= mean?
you must be referring to identifiers and keywords page at
http://docs.python.org/ref/identifiers.html
take it as meaning, "may expand to." in other words, when you are
trying to "parse" the language, meaning taking a look at the construct
of a valid Python program with the following substitutions:
identifier ::= (letter|"_") (letter | digit | "_")*
letter ::= lowercase | uppercase
lowercase ::= "a"..."z"
uppercase ::= "A"..."Z"
digit ::= "0"..."9"
identifier expands to exactly one occurrence of (letter or _) followed
by zero or more (*) occurrences of (letter or digit or _). so....
a variable such as 'testVar_123' matches the identifier token because
it can be broken down in that fashion. for example, 't' is matched by
letter -> lowercase -> 't' while 'estVar_123' is matched by zero or
more occurrences of (letter or digit or _) --> (letter, letter,
letter, letter, letter, letter, _, digit, digit, digit) -> lowercase,
lowercase, lowercase, uppercase, lowercase, lowercase, _, '1', '2',
'3') --> ('e', 's', 't', 'V', 'a', 'r', '_', '1', '2', '3').
you get the picture.
hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list