|
-
February 27th, 2006, 06:30 PM
#1
Regular Expression for an identifier token
I'm having trouble defining a regular expression for an identifier token. An identifier is defined as a letter followed by zero or more letters or digits or underscores. But there cannot be two consecutive underscores in the identifier. That's the part I'm having trouble with. How do I represent that there cannot be two consecutive underscores in the identifier?
Once I have this definition I can include it in the finite state machine that I'm making for my lexical analyzer.
Any help would be appreciated.
Thanks
-
February 27th, 2006, 07:41 PM
#2
Re: Regular Expression for an identifier token
It just means that word may begin with normal symbols, but once there is underscore, next stymbol is NOT underscore, and you may write it explicitly. It's actually simplier to draw as automaton.
For example, language words of symbols a and b, where b can't occur 2 times in a line is as follows (e is empty word):
"Programs must be written for people to read, and only incidentally for machines to execute."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|