Loading ...
Sorry, an error occurred while loading the content.
 

Re: [antlr-interest] Character replacement in the lexer

Expand Messages
  • iank@bearcave.com
    ... It sounds to me like you need to use a parser, rather than just the lexer. A parser can translate your source into tree form. A tree walker would then
    Message 1 of 2 , Dec 8, 2000
      > "Anna Winkler" <awinkler@...> writes:
      > Hi,
      >
      > I'm trying to replace characters using a lexer. Example of
      > replacements:
      > <> becomes !=
      > x[1,2,3] becomes x[1][2][3]
      >
      > The problem I'm having now is that an array index can be a function
      > call, and a function call can have expressions. At the moment I'm
      > looking at copying my expression hierarchy into this lexer, is that my
      > only option?
      >
      > Example of what I'm talking about:
      > x[foo(1, 2*3), 3] becomes x[foo(1, 2*3)][3]

      It sounds to me like you need to use a parser, rather than just the
      lexer. A parser can translate your source into tree form. A tree
      walker would then translate the tree into a tree for the new
      language. The new tree would then be translated back into text.

      Ian
      www.bearcave.com
      iank@...
    Your message has been successfully submitted and would be delivered to recipients shortly.