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?
 
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.
0
 
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
All Courses

From novice to tech pro — start learning today.