393 research outputs found
Parsing Expression Grammars Made Practical
Parsing Expression Grammars (PEGs) define languages by specifying
recursive-descent parser that recognises them. The PEG formalism exhibits
desirable properties, such as closure under composition, built-in
disambiguation, unification of syntactic and lexical concerns, and closely
matching programmer intuition. Unfortunately, state of the art PEG parsers
struggle with left-recursive grammar rules, which are not supported by the
original definition of the formalism and can lead to infinite recursion under
naive implementations. Likewise, support for associativity and explicit
precedence is spotty. To remedy these issues, we introduce Autumn, a general
purpose PEG library that supports left-recursion, left and right associativity
and precedence rules, and does so efficiently. Furthermore, we identify infix
and postfix operators as a major source of inefficiency in left-recursive PEG
parsers and show how to tackle this problem. We also explore the extensibility
of the PEG paradigm by showing how one can easily introduce new parsing
operators and how our parser accommodates custom memoization and error handling
strategies. We compare our parser to both state of the art and battle-tested
PEG and CFG parsers, such as Rats!, Parboiled and ANTLR.Comment: "Proceedings of the International Conference on Software Language
Engineering (SLE 2015)" - 167-172 (ISBN : 978-1-4503-3686-4
Customisable Handling of Java References in Prolog Programs
Integration techniques for combining programs written in distinct language
paradigms facilitate the implementation of specialised modules in the best
language for their task. In the case of Java-Prolog integration, a known
problem is the proper representation of references to Java objects on the
Prolog side. To solve it adequately, multiple dimensions should be considered,
including reference representation, opacity of the representation, identity
preservation, reference life span, and scope of the inter-language conversion
policies. This paper presents an approach that addresses all these dimensions,
generalising and building on existing representation patterns of foreign
references in Prolog, and taking inspiration from similar inter-language
representation techniques found in other domains. Our approach maximises
portability by making few assumptions about the Prolog engine interacting with
Java (e.g., embedded or executed as an external process). We validate our work
by extending JPC, an open-source integration library, with features supporting
our approach. Our JPC library is currently compatible with three different open
source Prolog engines (SWI, YAP} and XSB) by means of drivers. To appear in
Theory and Practice of Logic Programming (TPLP).Comment: 10 pages, 2 figure
Maintaining software through intentional source-code views
Maintaining the source code of large software systems is hard. One underlying cause is that existing modularisation mechanisms are inadequate to handle crosscutting concerns. We propose intentional source-code views as an intuitive and lightweight means of modelling such concerns. They increase our ability to understand, modularise and browse the source code by grouping together source-code entities that address the same concern. They facilitate software development and evolution, because alternative descriptions of the same intentional view can be checked for consistency and relations among intentional views can be defined and verified. Finally, they enable us to specify knowledge developers have about source code that is not captured by traditional program documentation mechanisms. Our intentional view model is implemented in a logic metaprogramming language that can reason about and manipulate object-oriented source code directly. The proposed model has been validated on the evolution of a medium-sized object-oriented application in Smalltalk, and a prototype tool has been implemented
DynamicSchema: a lightweight persistency framework for context-oriented data management
International audienceWhile context-oriented programming technology so far has focused mostly on behavioral adaptation, context-oriented data management has received much less attention. In this paper we make a case for the problem of context-oriented data management, using a concrete example of a mobile application. We illustrate some of the issues involved and propose a lightweight persistency framework, called DynamicSchema, that resolves some of these issues. The solution consists in a flexible reification of the database schema, as a convenient dynamic data structure that can be adapted at execution time, according to sensed context changes. Implementing our mobile application using this framework enabled us to reduce the complexity of the domain modeling layer, to facilitate the production of code with low memory footprint, and to simplify the implementation of certain scenarios related to context-dependent security concerns
- …