March 4th, 2010, 12:19 AM
Regular Expressions in Lex
Hi , i am working with regular expression and got into trouble how to differentiate between two patterns
the above rule of labelname will accept anything. now i want to have another rule
if i use first one i need to do further coding to get value of reg_num numerical value that why i want to use second one. problem is second rule fits in 1 rule also and so i get error results. is there any way i can have differen rules for second case and just able to have recognized patterns like p0 , P2 from second rule so that i dont need to do extra calculation to extract values as would have been in first case.
March 4th, 2010, 09:12 AM
What language are you writing this in? Is this actual code syntax or are you trying to explain something using this weird syntax?
The easiest way to get help is to tell us what language you're using, give us an example string, and tell us what you want to match.
Showing us what you have now is encouraged.
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.
March 4th, 2010, 10:20 PM
This is specification in lex for probable strings/token.
i can have label name as label1 or label2
can have identifiers as p1,p2 p3.
if you see both of grammar second one is nothing but subset of first one. so when p1, p2 , p3 are encountered lex will not able able to decide what to do and will give syntax error.
i want some way by which i can differentiate between two cases.
Thanks for your reply.
i had found and alternative solution of my problem.
Originally Posted by ManiacDan