• C

Handling Pascal Strings in LEX.

Hi,
I'm in the process of making a lex program to scan a Pascal source. But, i'm stuck at strings. How do i handle Pascal strings in lex? In Pascal, strings are enclosed by ' characters. The character ' may be included within a string by doubling it, eg: 'don''t'. I also need to return the value of the string along with the STRING token. Thanks.
joeDreamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sumant032199Commented:
When your lex program identifies a ' character then you can enter in a special case statement.
Then check for what is next character?
If it is other than ' then string begins.
If it is ' then something like don''t
If previously there was a ' character and again you find a ' in a sequence then It is a end of string.

One thing for sure whenever you find ' then check that it is not repeated on a sequence.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sumant032199Commented:
You may need recursive function for that.
0
gaurangbhattCommented:
It means that you need to look ahead for the next token and take actions based on that.

Is it correct Sumant?
And I think moreover that is the way the compiler is designed to work,b'cos there can't be any other way or if there is one than might be this is the most efficient of those.
0
sumant032199Commented:
joeDream has fast asleeped!
0
joeDreamAuthor Commented:
what's that supposed to mean?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.