HELP: Recursion in lex, combining two lex files (Suresh Kolichala)
Thu, 5 Jan 1995 05:41:42 GMT

          From comp.compilers

Related articles
HELP: Recursion in lex, combining two lex files (1995-01-05)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Suresh Kolichala)
Keywords: flex, lex, question, comment
Organization: Compilers Central
Date: Thu, 5 Jan 1995 05:41:42 GMT

I am looking for any ideas on this specific requirement using [f]lex/yacc.
I am not a very experienced user of lex/yacc and don't know if any of
my questions have an obvious answers. Any way, here are my questions ...

1. Recursion : I want to apply the lexical substitution rules recursively.
      Using REJECT for every rule would make it costly. Also, that is not
      what I am exactly looking for.

      Let me elaborate my requirement :

      I want to parse every word separated by spaces, process it from backwards,
      look for certain matchings and then truncate the processed portion and
      send rest of the string to be filtered through the lexical rules again
      for any further substitutions. This goes-on until the complete word
      is processed.

2. This is a different requirement. I have two sets of lex rules.
      I want to apply first set of rules and then pass the output through
      the second set. Right now, I use two different ".l" files and need to
      run two executables to piping the output of one to the other. I want
      to combine these two into a single C file. Any ideas ?

      I have been thinking in the following lines :

      Can I make yylex() to take input from a buffer and then let it make
      the appropriate modifications to the buffer itself ? Would it suffice
      to redefine (by using #define) YY_INPUT to take input from a buffer.

I appreciate any responses,

Suresh Kolichala e-mail:
IBM, Boca Raton (On assignment with IBM) Phone: (407)-443-6585
[For #1, I suspect that a combination of trailing context and REJECT will do
the trick as efficiently as anything else. For #2, redefining YY_INPUT is
indeed the way that you tell flex to take its input from somewhere other
than a stdio file. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.