================================================================================ Metaborg: Experiments in Shitty Documentation ================================================================================ Most useful links: http://catamaran.labs.cs.uu.nl/twiki/pt/bin/view/Stratego/StrategoXTAnAnnotatedBibliography http://catamaran.labs.cs.uu.nl/twiki/pt/bin/view/Stratego/MetaProgrammingWithConcreteObjectSyntax ================================================================================ METHODOLOGIES ================================================================================ * MetaBorg MetaBorg is a method for providing concrete syntax for domain abstractions to the application programmer. The method consists of embedding domain-specific languages in a general purpose host language and assimilating the embedded domain code into the surrounding host code. The method is supported by proven and available technology, i.e. the syntax definition formalism SDF and the program transformation language and toolset Stratego/XT. ================================================================================ TERM REWRITING ================================================================================ * ASF [At CWI (Amsterdam) rather than UU (Utrecht)?] ASF is a term rewriting language with conditional rewrite rules and concrete syntax. It compiles to efficient C code. * Stratego Stratego is a language for program transformation based on the paradigm of rewriting strategies. Basic transformation steps are specified by means of conditional rewrite rules. A rule recognizes a subterm to be transformed by pattern matching and replaces it with a pattern instance. Specification of transformations in abstract syntax becomes cumbersome when the patterns become large. Therefore, Stratego supports specification of patterns in the concrete syntax of the object language. This is especially useful in template-based program generation, where large fragments of object language programs are instantiated. * XT XT is a bundle of transformation tools that combines Stratego, a language for transformation of abstract syntax trees, with tools for other aspects of program transformation. Stratego only deals with transformation of programs represented by means of terms. Parsing and pretty-printing is provided by the XT bundle of transformation tools, which combines Stratego with the Syntax Definition Formalism SDF and the Generic Pretty-Printing Package GPP. ================================================================================ SYNTAX SPECIFICATION, PARSING, UNPARSING ================================================================================ * SDF The Syntax Definition Formalism SDF supports high-level, declarative, and modular definition of the syntax of programming languages and data formats. The formalism integrates the definition of lexical and context-free syntax. The modularity of the formalism implies that it is possible to easily combine two languages or to embed one language into another. - declarative disambiguation constructs (priorities, associativities, and more) - regex shorthands - all non-circular CFG's allowed * GPP The GPP package is a tool suite for generic pretty-printing. GPP supports pretty-printing of parse-trees in the AsFix format with comment preservation and of abstract syntax trees. GPP supports the output formats plain text, LaTeX, and HTML. Formattings are defined in pretty print tables, which can be generated from SDF syntax definitions. * SGLR SGLR, Scannerless Generalized LR Parser, is an implementation of Tomita's Generalized LR algorithm with extensions for scannerless parsing. The SGLR package contains the tool sglr, which is a generic parser. The sglr parser interprets parse tables generated by the parse table generator from an SDF2 syntax definition. The parser outputs parse trees or parse forests if there is more then one possible parse tree. ================================================================================ ABSTRACT SYNTAX ================================================================================ * ATerm The foundation of XT is the ATerm format for exchange of structured data such as abstract syntax trees. The format essentially consists of first-order prefix terms. The format is supported by libraries for C, Java, and Haskell, which support reading and writing of ATerms. * AsFix AsFix (ASF+SDF fixed format) is a format for representing parse trees in the ATerm format. Currently two versions of AsFix are in used: AsFix2ME and AsFix2. AsFix2 is extremely verbose since layout and literals have a structured representation in AsFix2. AsFix2ME is a more concise since lists, layout and literals are flattened. This is the parse tree format that is used in the ASF+SDF Meta-Environment. ================================================================================ APPLICATIONS ================================================================================ * JavaBorg Java-borg is a collection of examples for embeddings domain-specific languages in Java. * JavaFront Java-front adds support for Java program transformation to StrategoXT. It provides a handcrafted SDF syntax definition and pretty-printer for Java (J2SE 5.0). * JavaSwul Java-Swul is an embedding of a domain-specific language in Java of the SWING userinterface API. ================================================================================ PAPER ================================================================================ * Design issues + meta-language that supports different object language + meta-language parameterized over object language with user-definable quotation/antiquotation syntax + need composable classes of grammars (i.e., not LL or LR) + need extensible lexical specifications, too + injections from object language to meta-language + injection of meta-variables into concrete object syntax - hygiene - let-syntax - specifying syntactic "holes" (a la Abadi-Cardelli) * Example: Tiger instrumentation - Figure 1: syntax definition o CFG module, with sorts and constructors o AST module, with node sorts - Figure 2: strategies o defined using concrete object language syntax o defined using AST's - Figure 4: extending the meta-language o this is just a methodology o user has to explicitly extend Stratego syntax o could be automated, but they don't think it should (cop out) - meta-variables (BLEAH) - "meta-explode" = transformation rules for meta-language