The main goals of the redesign is performance and flexibility. The speedup ranges between 2-5x. This is achieved through the idea of a kind of a parser compiler that performs a static analysis of the parse tree to identify patterns that can be optimized and then changes the actual parser execution.
The original implementation of the compiler was actually implemented in PetitParser. However, the problem was that the resulting parser was not easy to understand. This was the main reason that prompted the redesign of PetitParser. In PetitParser2 the concept of a Parser is split in two:
Nodes: These essentially provides only the AST of the parser, but without actual logic inside. They mirror the previous PPParser classes.
Visitors. These provide the actual parsing behavior. Optimizations are implemented in this hierarchy.
For a typical external user, PetitParser2 has the same structure as PetitParser. The main difference is that asParser is changed to asPParser. For example, the following original snippet:
#letter asParser, #any asParser star
#letter asPParser, #any asPParser star
In this way, the two versions of PetitParser can co-exist in the same image to ease the transition. This transition is needed for parsers that rely on deeper constructs from the original PetitParser, such as concrete names of classes.
Another new feature is the availability of streams. The original PetitParser required the whole string to be present in memory to allow for indefinite backtracking. PetitParser2 offers stream utilities that apply parsers on a stream by keeping a buffer in memory for backtracking purposes.
Of course, the new version comes with all development tools that we got used with PetitParser. The nice thing is that the tools work even when we are using the optimized version of a parser.
For example, the picture below shows the PetitParser browser opened on the Smalltalk parser.
The one addition is a larger run button which performs the optimized parsing. Triggering it for our case renders the result as shown below. The only difference is that in the above version, there were 907 individual parsers involved, while the optimized version only used 258 of them.
To get a better feeling of how the magic happens, let’s look at a small sequence parser.
#any asPParser star
Inspecting the parser allows us to play with the sampler.
The unoptimized version of the parser triggers independent parsers for each of the letters, and then concatenates the results in another collection. However, triggering the optimized version only involves one parser that knows how to consume the entire sequence in one collection.
All in all, PetitParser2 is an exciting development. Take a look at let us know what you think.
At ESUG, I gave a talk about the Glamorous Toolkit, and the talk is now online. We have announced the Glamorous Toolkit project two years ago at the same conference. On that occasion I argued that IDEs should have different properties than what typical IDEs have to offer today. Over the last two years, we introduced 4 significant tools inside Pharo, namely Inspector, Playground, Spotter, and Debugger, and in this talk I focused on how these tools can affect the way you think about programs and programming.
Please take a look, and let us know what you think.
We are very happy to make the following announcement:
Lam Research, a leading supplier of wafer fabrication equipment and services to the global semiconductor industry, is an experienced user of the Smalltalk programming language. Smalltalk is a key component in Lam's software control system for a broad range of the equipment it manufactures. Tudor Girba is a leading member of the tools and environment development effort in Pharo, having architected the Glamorous Toolkit for live programming. Eliot Miranda is author of the Cog virtual machine that underlies Pharo and other Smalltalk dialects.
Lam has engaged Tudor and Eliot to explore potential enhancements in Lam's use of Smalltalk. These enhancements range from running highly optimized Smalltalk on low cost, single board computers, to enhancing Lam's Smalltalk development practices with state-of-the-art live programming. During the engagement, Tudor and Eliot successfully moved a key communication component of the control system to Pharo. It was a challenging task aimed at extending the reach of Lam’s system to the Pharo world including the option of executing on ARM processors.
Cheers, Tudor Girba, Eliot Miranda and Chris Thorgrimsson
Posted by Tudor Girbaat 25 August 2016, 11:16 amlink
Over the last couple of weeks I worked on a new importer for Java code that can be used for Moose, and I am happy to announce that I released version 1.0.1.
jdt2famix is an open-source project, and the repository can be on Github. It is implemented in Java as a standalone project, and it is based on JDT Core (developed as part of the Eclipse project and available under the EPL2 license) and Fame for Java (originally developed by Adrian Kuhn and is available under the LGPL license).
The current implementation has an extensive coverage of entities that it can import, namely:
Go to the root folder where you have the sources and dependency libraries of a Java system (e.g., mysystem)
The result will be an MSE file having the same name as the name of the folder from which you executed the command (e.g., mysystem.mse).
Let’s look at a concrete example. For this purpose, we pick the Maven project. We first download the 3.3.9 sources. These are only the plain sources, but to be able to import the complete model, we also need to have the dependencies available in the same folder.
As Maven is a Maven project (no pun intended), we can use the configuration to download the dependencies locally: