Re: Looking for Program
- Posted by DB James <larch at adelphia.net> Aug 26, 2005
- 648 views
Tone Škoda wrote: > > DB James wrote: > > > > Robert Craig wrote: > > > > > > Greg Haberek wrote: > > > > don cole wrote: > > > > > Somewhere in the Archives or Euforum, I saw something about an > > > > > Euphoria Program that analized your program and gave you a list of > > > > > all the Constants , Atoms, Integers, Sequences, objects and especially > > > > > > > > > > Does anyone know what this program is or was? > > > > > > > > Parser for Euphoria Programs by Humberto Yeverino > > > > <a > > > > href="http://www.rapideuphoria.com/euparse.zip">http://www.rapideuphoria.com/euparse.zip</a> > > > > > > > > I've used it before, but I think it needs work. It just grabs all the > > > > info without really organizing it too well. One thing I'd like it to > > > > do is tell me what the parameters of a routine are and their types, in > > > > order. Then I could use it to parse include files for dll wrappers. > > > > > > It should be pretty easy to make a program like this now, > > > using the PD interpreter source (euphoria\source). > > > After parsing, instead of executing the program, you'd display the > > > symbol table (SymTab). (skip the temps and literal values, > > > and see global.e for the symbol table fields). > > > > > > Regards, > > > Rob Craig > > > Rapid Deployment Software > > > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> > > > > > > > Hi, > > > > As to Robert's suggestion, I tried it quickly and managed to send all the > > tokens to > > a file, and to indicate they were one of the following: > > > > 1)keywords had no S_TOKEN (identifying number) but themselves (i.e. "if" is > > represented > > by "IF") > > > > 2)procedure names are S-TOKENed by "PROC" > > > > 3)function names are S-TOKENed by "FUNC" > > > > 4)type names are S-TOKENed by "TYPE" > > > > 5)just about everything else is S-TOKENed by "VARIABLE" > > > > It's a start, but so far I am hesitant to use the word "easy" for outputting > > really > > useful information for programmers with the PD interpreter. Any hints? At > > my level > > of programming, a lot of things are not so easy :^D > > > > --Quark > > > > make a small test program and then write Symtab to Symtab.txt and comprare > what you > see - that is the easiest and surest way to do it. > > > S_VTYPE is for routines 0, for variables it is integer_type, sequence_type... > > S_NAME is name of routine or variable. > > You can get list of all arguments of routine like this: > sub = routine's symtab_index > sym = SymTab[sub][S_NEXT] > for i = 1 to SymTab[sub][S_NUM_ARGS] do > <sym is argument> > sym = SymTab[sym][S_NEXT] > end for > > You can get list of all variables of routine like this: > sub = routine's symtab_index > <first skip arguments like in the code above> > v = SymTab[sub][S_NEXT] > while v != 0 and > (SymTab[v][S_SCOPE] = SC_PRIVATE do > <v is private variable of routine> > v = SymTab[v][S_NEXT] > end while > > > As for the GUI I think a html page with hyperlinks would work good and would > be easy > to write. > > make a html page for every source file, put them in directory named after main > program > file + "_analyze". if directory already exists show msgbox() to user and > abort. > > - main page is "all_files.htm". on that page is a list of hyperlinks of all > files program > includes, in order as they are included > > - for every source file make a page. on top of page is a list of hyperlinks to > all > global and global-to-file things in file, in order as they appear in file. > only routines > have links. > > - for every routine make a list of variables it declares, in order as they > appear in > file: > procedure test (sequence msg) > atom answer > sequence built_msg > integer do_delete -- maybe group them by type to save space > > > i'm not sure if it is possible to get line number of symbol table entry. Hello Tone, Thanks much for this reply. It gives me quite a bit to think about and to try, especially the list of variables in routines. I found your speculations about using HTML for the report interesting, though I haven't done much with it before. I remember having written a little program to convert a long chunk of text to linked HTML pages, but that's all I've done with it so far. My guess at the moment is that what would be useful to the programmer is not defined clearly now. A way to start would be to write a clear simple report of all the components to a text file: all the routines and variables and constants, possibly with actual line numbers where they first occur, the number of calls, etc. Then people would have something concrete to react to, and they would say it should have this or that feature (including hyperlinks, maybe). Then anyone interested could try modifying the report, this would continue until enough people say "this is helpful, my coding is being improved". My main problem so far in working at this sort of thing has been parsing issues. Robert's parser plows ahead flawlessly and it would be nice to capitolize on it. --Quark