Results 1 - 10
of
20
Programmable Syntax Macros
, 1993
"... Lisp has shown that a programmable syntax macro system acts as an adjunct to the compiler that gives the programmer important and powerful abstraction facilities not provided by the language. Unlike simple token substitution macros, such as are provided by CPP #the C preprocessor#, syntax macros ope ..."
Abstract
-
Cited by 100 (0 self)
- Add to MetaCart
Lisp has shown that a programmable syntax macro system acts as an adjunct to the compiler that gives the programmer important and powerful abstraction facilities not provided by the language. Unlike simple token substitution macros, such as are provided by CPP #the C preprocessor#, syntax macros operate on Abstract Syntax Trees #ASTs#. Programmable syntax macro systems have not yet been developed for syntactically rich languages such as C because rich concrete syntax requires the manual construction of syntactically valid program fragments, which is a tedious, di#cult, and error prone process. Also, using two languages, one for writing the program, and one for writing macros, is another source of complexity. This research solves these problems byhaving the macro language be a minimal extension of the programming language, byintroducing explicit code template operators into the macro language, and by using a type system to guarantee, at macro de#nition time, that all macros and macro functions only produce syntactically valid program fragments. The code template operators make the language context sensitive, which requires changes to the parser. The parser must perform type analysis in order to parse macro de#nitions, or to parse user code that invokes macros. 1
Concrete syntax for objects. Domain-specific language embedding and assimilation without restrictions
- Proceedings of the 19th ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications (OOPSLA’04
, 2004
"... Application programmer’s interfaces give access to domain knowledge encapsulated in class libraries without providing the appropriate notation for expressing domain composition. Since object-oriented languages are designed for extensibility and reuse, the language constructs are often sufficient for ..."
Abstract
-
Cited by 59 (15 self)
- Add to MetaCart
Application programmer’s interfaces give access to domain knowledge encapsulated in class libraries without providing the appropriate notation for expressing domain composition. Since object-oriented languages are designed for extensibility and reuse, the language constructs are often sufficient for expressing domain abstractions at the semantic level. However, they do not provide the right abstractions at the syntactic level. In this paper we describe MetaBorg, a method for providing concrete syntax for domain abstractions to application programmers. 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. Instead of extending the implementation of the host language, the assimilation phase implements domain abstractions in terms of existing APIs leaving the host language undisturbed. Indeed, Meta-Borg can be considered a method for promoting APIs to the language level. 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. We illustrate the method with applications in three domains: code generation, XML generation, and user-interface construction.
Typing dynamic typing
- ICFP ’02: Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming
, 2002
"... Even when programming in a statically typed language we every now and then encounter statically untypable values; such values result from interpreting values or from communicating with the outside world. To cope with this problem most languages include some form of dynamic types. It may be that the ..."
Abstract
-
Cited by 53 (1 self)
- Add to MetaCart
Even when programming in a statically typed language we every now and then encounter statically untypable values; such values result from interpreting values or from communicating with the outside world. To cope with this problem most languages include some form of dynamic types. It may be that the core language has been explicitly extended with such a type, or that one is allowed to live dangerously by using functions like unsafeCoerce. We show how, by a careful use of existentially and universally quantified types, one may achieve the same effect, without extending the language with new or unsafe features. The techniques explained are universally applicable, provided the core language is expressive enough; this is the case for the common implementations of Haskell. The techniques are used in the description of a type checking compiler that, starting from an expression term, constructs a typed function representing the semantics of that expression. In this function the overhead associated with the type checking is only once being paid for; in this sense we have thus achieved static type checking.
Growing Languages with Metamorphic Syntax Macros
- In Proceedings of Workshop on Partial Evaluation and Semantics-Based Program Manipulation, PEPM 2002. ACM
, 2000
"... From now on, a main goal in designing a language should be to plan for growth." Guy Steele: Growing a Language, OOPSLA'98 invited talk. We present our experiences with a syntax macro language which we claim forms a general abstraction mechanism for growing (domain-specific) extensions of programmin ..."
Abstract
-
Cited by 37 (4 self)
- Add to MetaCart
From now on, a main goal in designing a language should be to plan for growth." Guy Steele: Growing a Language, OOPSLA'98 invited talk. We present our experiences with a syntax macro language which we claim forms a general abstraction mechanism for growing (domain-specific) extensions of programming languages. Our syntax macro language is designed to guarantee type safety and termination. A concept of metamorphisms allows the arguments of a macro to be inductively defined in a meta level grammar and morphed into the host language. We also show how the metamorphisms can be made to operate simultaneously on multiple parse trees at once. The result is a highly flexible mechanism for growing new language constructs without resorting to compile-time programming. In fact, whole new languages can be defined at surprisingly low cost. This work is fully implemented as part of the <bigwig> system for defining interactive Web services, but could find use in many other languages. 1.
Metaborg in action: Examples of domain-specific language embedding and assimilation using Stratego/XT
- IN PARTICIPANTS PROCEEDINGS OF THE SUMMER SCHOOL ON GENERATIVE AND TRANSFORMATIONAL TECHNIQUES IN SOFTWARE ENGINEERING (GTTSE’05
, 2005
"... General-purpose programming languages provide limited facilities for expressing domain-specific concepts in a natural manner. All domain concepts need to be captured using the same generic syntactic and semantic constructs. Generative programming methods and program transformation techniques can be ..."
Abstract
-
Cited by 16 (4 self)
- Add to MetaCart
General-purpose programming languages provide limited facilities for expressing domain-specific concepts in a natural manner. All domain concepts need to be captured using the same generic syntactic and semantic constructs. Generative programming methods and program transformation techniques can be used to overcome this lack of abstraction in general-purpose languages. In this tutorial we describe the METABORG method for embedding domainspecific languages, tailored syntactically and semantically to the application domain at hand, in a general-purpose language. METABORG is based on Stratego/XT, a language and toolset for the implementation of program transformation systems, which is used for the definition of syntactic embeddings and assimilation of the embedded constructs into the surrounding code. We illustrate METABORG with three examples. JavaSwul is a custom designed language for implementing graphical user-interfaces, which provides high-level abstractions for component composition and event-handling. JavaRegex is a new embedding of regular expression matching and string rewriting. JavaJava is an
Semantically-Sensitive Macroprocessing
, 1989
"... Conventional procedure and type definition mechanisms are not sufficiently powerful to express many programming abstractions that can be captured by syntactic transformations. Unfortunately, conventional macroprocessing is oblivious to the semantics of the base language, resulting in scoping anom ..."
Abstract
-
Cited by 15 (0 self)
- Add to MetaCart
Conventional procedure and type definition mechanisms are not sufficiently powerful to express many programming abstractions that can be captured by syntactic transformations. Unfortunately, conventional macroprocessing is oblivious to the semantics of the base language, resulting in scoping anomalies, poor handling of static semantic errors, and an inability to perform transformations dependent on semantic attributes of the manipulated program. We introduce a new mechanism, semantic macros, which permit such transformations a significant level of access to the static semantic properties of the program fragments they manipulate. In this way, new static semantic processing, including compilation of embedded languages with a rich static semantics of their own, can be incorporated into user-defined language extensions. A proof-of-concept language, XL, is described which embodies this mechanism. Sponsored by the Defense Advanced Research Projects Agency (DoD), monitored by Spac...
Generalized type-based disambiguation of meta programs with concrete object syntax
- Proceedings of the Fourth International Conference on Generative Programming and Component Engineering (GPCE’05), volume 3676 of Lecture Notes in Computer Science
, 2005
"... Abstract. In meta programming with concrete object syntax, object-level programs are composed from fragments written in concrete syntax. The use of small program fragments in such quotations and the use of meta-level expressions within these fragments (anti-quotation) often leads to ambiguities. Thi ..."
Abstract
-
Cited by 10 (8 self)
- Add to MetaCart
Abstract. In meta programming with concrete object syntax, object-level programs are composed from fragments written in concrete syntax. The use of small program fragments in such quotations and the use of meta-level expressions within these fragments (anti-quotation) often leads to ambiguities. This problem is usually solved through explicit disambiguation, resulting in considerable syntactic overhead. A few systems manage to reduce this overhead by using type information during parsing. Since this is hard to achieve with traditional parsing technology, these systems provide specific combinations of meta and object languages, and their implementations are difficult to reuse. In this paper, we generalize these approaches and present a language independent method for introducing concrete object syntax without explicit disambiguation. The method uses scannerless generalized-LR parsing to parse meta programs with embedded objectlevel fragments, which produces a forest of all possible parses. This forest is reduced to a tree by a disambiguating type checker for the meta language. To validate our method we have developed embeddings of several object languages in Java, including AspectJ and Java itself. 1
Preprocessing C++ : Substitution and Composition
- PROCEEDINGS OF THE EASTERN EUROPEAN CONFERENCE ON THE TECHNOLOGY OF OBJECT ORIENTED LANGUAGES AND SYSTEMS
, 1999
"... Problems with the lexical substitution mechanism of the C preprocessor are well known. We resolve these problems with a new syntax-based substitution mechanism for C++ based on meta-variables and metafunctions. Implementation of these meta-concepts in a C++ style leads naturally to meta-expressions ..."
Abstract
-
Cited by 4 (1 self)
- Add to MetaCart
Problems with the lexical substitution mechanism of the C preprocessor are well known. We resolve these problems with a new syntax-based substitution mechanism for C++ based on meta-variables and metafunctions. Implementation of these meta-concepts in a C++ style leads naturally to meta-expressions and then meta-statements and a generalisation of C++ syntax. We show how meta-compilation renders the C preprocessor redundant, and offers a more intuitive and powerful programming language in which pattern solutions can be provided and Aspect-Oriented programming practiced. In a companion paper [21] we go one stage further, putting the concepts together in the context of meta-classes where meta-programming and reflection are supported at compile-time.
Update Plans for Parallel Architectures
- Abstract Machine Models for Parallel and Distributed Computing
, 1996
"... This paper proposes Update Plans as a specification formalism for abstract machines for parallel architectures. Update Plans are a formal specification language for abstract and concrete machines. First results in using Update Plans to specify parallel architectures are illustrated, and some suggest ..."
Abstract
-
Cited by 3 (2 self)
- Add to MetaCart
This paper proposes Update Plans as a specification formalism for abstract machines for parallel architectures. Update Plans are a formal specification language for abstract and concrete machines. First results in using Update Plans to specify parallel architectures are illustrated, and some suggestions for further research are made.
SugarJ: Librarybased syntactic language extensibility
- In Proceedings of Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA). ACM
, 2011
"... Existing approaches to extend a programming language with syntactic sugar often leave a bitter taste, because they cannot be used with the same ease as the main extension mechanism of the programming language—libraries. Sugar libraries are a novel approach for syntactically extending a programming l ..."
Abstract
-
Cited by 3 (1 self)
- Add to MetaCart
Existing approaches to extend a programming language with syntactic sugar often leave a bitter taste, because they cannot be used with the same ease as the main extension mechanism of the programming language—libraries. Sugar libraries are a novel approach for syntactically extending a programming language within the language. A sugar library is like an ordinary library, but can, in addition, export syntactic sugar for using the library. Sugar libraries maintain the composability and scoping properties of ordinary libraries and are hence particularly well-suited for embedding a multitude of domain-specific languages into a host language. They also inherit self-applicability from libraries, which means that sugar libraries can provide syntactic extensions for the definition of other sugar libraries. To demonstrate the expressiveness and applicability of sugar libraries, we have developed SugarJ, a language on top of Java, SDF and Stratego, which supports syntactic extensibility. SugarJ employs a novel incremental parsing technique, which allows changing the syntax within a source file. We demonstrate SugarJ by five language extensions, including embeddings of XML and closures in Java, all available as sugar libraries. We illustrate the utility of selfapplicability by embedding XML Schema, a metalanguage to define XML languages.

