An interesting Parser problem

"sachin.goyal.new@gmail.com" <sachin.goyal.new@gmail.com>
Thu, 29 Nov 2007 01:34:05 -0800 (PST)

          From comp.compilers

Related articles
An interesting Parser problem sachin.goyal.new@gmail.com (sachin.goyal.new@gmail.com) (2007-11-29)
Re: An interesting Parser problem torbenm@app-4.diku.dk (2007-11-30)
Re: An interesting Parser problem DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-11-30)
Re: An interesting Parser problem holgersiegel74@yahoo.de (Holger Siegel) (2007-11-30)
Re: An interesting Parser problem cfc@shell01.TheWorld.com (Chris F Clark) (2007-11-30)
Re: An interesting Parser problem gene.ressler@gmail.com (Gene) (2007-12-02)
Re: An interesting Parser problem rlwatkins@gmail.com (RLW) (2007-12-08)
| List of all articles for this month |

From: "sachin.goyal.new@gmail.com" <sachin.goyal.new@gmail.com>
Newsgroups: comp.compilers
Date: Thu, 29 Nov 2007 01:34:05 -0800 (PST)
Organization: Compilers Central
Keywords: tools, parse, question
Posted-Date: 29 Nov 2007 23:58:46 EST

We are planning to make an intelligent text editor (Why is not
important, we have to do it.)


The text editor would show declarations, definitions, function calls
etc in a logical grouping and would also support intelligent text
editing for eg. It would change the name of a variable "foo" in a
higher scope but other variables with same name "foo" in other scopes
present will not be affected. eg.


{ // higher scope
int foo;
foo = 1;
func (foo);


    { // lower scope
          int foo;
    }
}




So we need to construct a parse tree of the input. But after editing,
we want to conserve the comments and white space as much as possible
so that the user does not see drastic changes to original code.


One approach is to store to file name and offset information of each
token in the parse tree. During decompiling, text between two offsets
is copied as such from original file if its not edited. If edited,
then the new text is used.


So the first issue is to find the offset of each token in lex (yacc ?)
This should also handle if some include file construct like "include
abc.xyz" is encountered. In such a case, filename and offset from new
file should be returned. Is there any other tricky case possible ?



Post a followup to this message

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