For Programmers: Free Programming Magazines  


Home > Archive > Compilers > September 2004 > Loop question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Loop question
skyhook

2004-09-30, 5:00 am

Hello,

I am trying to implement a simple loop. E.g. something like

repeat 100
command1
command2
endrepeat
command3
command1

The idea is to switch to an exclusive start state whenever "repeat" is matched. Then all commands of the repeat body should be expanded and written into a temporary file.
If "endrep" is matched, lex should return to the standard state.
Then the input files would have to be switched.

I am not sure about the switching. Maybe yacc could be used to set a global variable, too.

I aam trying to get familiar with lex/yacc, but loops seem to be quite hard. The O'Reilly book sort of skips this topic, too :-(

Any suggestions would be highly appreciated!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com