Handling Pascal Strings in LEX.

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.
Who is Participating?
sumant032199Connect With a Mentor Commented:
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.
You may need recursive function for that.
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.
joeDream has fast asleeped!
joeDreamAuthor Commented:
what's that supposed to mean?
All Courses

From novice to tech pro — start learning today.