tag:blogger.com,1999:blog-26866996.post347939446201530386..comments2023-05-16T03:14:55.163-05:00Comments on JFKBits: XML-Driven Language ToolsUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-26866996.post-66875293142412746722007-02-23T09:58:00.000-06:002007-02-23T09:58:00.000-06:00Hmmm. I haven't read much of the Wave documentatio...Hmmm. I haven't read much of the Wave documentation, just a lot of discussions about it and anticipated applications, so it's possible that I have mis-read those.Susan's Husbandhttps://www.blogger.com/profile/02862667802025231163noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-79737101651425558352007-02-22T14:11:00.000-06:002007-02-22T14:11:00.000-06:00I missed the part of the Wave description where it...I missed the part of the Wave description where it gave you access to the syntactic structure -- all I saw was it talking about lexing, i.e. emitting token streams.<BR/><BR/>I suppose in the example you gave, of a tool that want to discover the members of a class, you could write a recursive descent parser that simply skips lots of its input. When you hit a method definition, you skip it. Still, you need to "count parentheses", don't you?<BR/><BR/>A class like this:<BR/>class Complex<BR/>{<BR/> double re;<BR/> double im;<BR/> double abs()<BR/> {<BR/> return sqrt(re*re+im*im);<BR/> }<BR/> double angle()<BR/> {<BR/> return atan(im/re);<BR/> }<BR/> // what if members are declared here?<BR/>};<BR/><BR/>would generate a token stream like this:<BR/><BR/>CLASS ID:Complex LBRACE DOUBLE ID:re SEMI DOUBLE ID:im SEMI DOUBLE ID:abs LPAREN RPAREN LBRACE RETURN ID:sqrt LPAREN ID:re TIMES ID:re PLUS ID:im TIMES ID:im RPAREN SEMI RBRACE DOUBLE ID:angle LPAREN RPAREN LBRACE RETURN ID:atan LPAREN ID:im DIVIDE ID:re RPAREN SEMI RBRACE RBRACE SEMI<BR/><BR/>The token stream lacks the syntactic structure, so even if you were only interested in gather members and wanted to skip the method declarations, you'd have to count left and right braces and make sure you didn't something out. I mean, leave something out.jfkleinhttps://www.blogger.com/profile/10941573678144316048noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-64943103292813968632007-02-22T13:01:00.000-06:002007-02-22T13:01:00.000-06:00There are a lot of tools out there that want to do...There are a lot of tools out there that want to do meta-programming with a C++ base (the <A HREF="http://trolltech.com" REL="nofollow">QT graphics library</A> comes to mind, but there are a lot of other tools that do that (e.g., the ITE, if you remember that). What Wave does is support that kind of activity by letting client code iterate over the syntactic elements like you would an XML document. E.g., client code can iterate until it gets to class definition, then iterate over the members and their types and emit ancillary code on the side. Wave (AFAIK) is designed with that kind of application in mind, although it might also be useful for development environments.Susan's Husbandhttps://www.blogger.com/profile/02862667802025231163noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-56351310137594131332007-02-22T11:52:00.000-06:002007-02-22T11:52:00.000-06:00I agree, there's nothing super special about XML. ...I agree, there's nothing super special about XML. You get existing tools to handle marshalling and unmarshalling (parsing and serializing), to format it, and all that, but you're right, that's not the main goal.<BR/><BR/>Wave is a "C++ lexer with ISO/ANSI Standards conformant preprocessing capabilities". I have to think about that a little bit, it's different than what I'd been imagining, namely a parser emitting an AST in the structured persistent format (XML, LISP, etc.). I'm trying to imagine what utility just the lexer would be. <BR/><BR/>I have heard of using just the lexer portion to do tricks with syntax-aware editors. If you're editing a large file, thousands of lines, you run the lexer pass on the whole file after some typing and see if the file's token sequence has changed, and if so where. This is faster than re-parsing the whole thing every time the user pauses in typing.jfkleinhttps://www.blogger.com/profile/10941573678144316048noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-57607251576497448972007-02-22T11:31:00.000-06:002007-02-22T11:31:00.000-06:00I think Wave is a better approach, at least for C+...I think <A HREF="http://www.boost.org/libs/wave/index.html" REL="nofollow">Wave</A> is a better approach, at least for C++. XML is just a mechanism. The goal is to be able to operate on the semantic information in the source code.Susan's Husbandhttps://www.blogger.com/profile/02862667802025231163noreply@blogger.com