views:

80

answers:

1

In the process of developing a new language. How can be related the "high level" concepts such as "LALR parser", "abstract syntax tree", "context-free grammars", etc. with other "low level" concepts like the specific grammar rules "A -> B".

I mean as some kind of metalanguage relationship, or similar. Any ideas or suggestions to look more information on this topic? Please, feel free to rephrase my question to gain some clarity.

Any help will be greatly appreciated.

+2  A: 

Usually these entities (grammar rules, parsers, ASTs) have conceptual relations as captured by books such as the Dragon compiler book (already mentioned in a comment). I don't think these relations are very interesting when it comes to designing a new langauge; all you really care about is the syntax of the language (often expressed as a "context-free" grammar with additional constraints, and the semantics of the langauge (usually expressed as a very big reference documents, sometimes expressed in a formal notation such as denotational semantics that can interpret an abstract parse tree produced by magic.

"Real" relations occur when you have machinery that ties them together: If I give grammar A to parser generator B, and use the result to process source code S, I may get AST T. At this level, you aren't designing your langauge so much as implementing it. What you want here is an integrated set of tools for processing your language definition; ideally, it will accept your grammar and semantic notation directly. There aren't any practical tools that do both of these ideally that I know about, so you have to choose among those that do exist.

Two tools that can be used for this to varying degrees of effectiveness are ANTLR and my DMS Software Reengineering Toolkit.

DMS provides at least one way in which semantics can be defined, by providing means for writing down "algebraic" laws of equivalence between language forms. In essence, you can say this language form is equivalent to that langauge form by writing pattern1 = pattern2 just like you do with algebra. You can see how this is done using algebra as an example.

Ira Baxter
A tool I've been working on that does something similar: http://metasharp.codeplex.com
justin.m.chase
Hello, thank you very much for your detailed reply. I have been reviewing in detail the links you sent me and I have clarified some doubts. I think you've hit the mark in the second paragraph.But if the context was the reuse of developed languages, lets say for similar domains, do you think would be useful such a tool?
amorales
Hey, http://metasharp.codeplex.com/ also looks great! Thanks for the links.
amorales
ANTLR and DMS are pretty good for definining/processing both "developed" languages (those well documented in the literature) and building new ones.
Ira Baxter