Skip to content

GSoC 2018: Autolev Parser (using ANTLRv4): Final Report

Nikhil Pappu edited this page Aug 14, 2018 · 2 revisions

About Me:

I am Nikhil Pappu, an undergraduate Computer Science student at the International Institute of Information Technology, Bangalore.

About the Project:

Autolev (now superseded by MotionGenesis) is a domain specific language used for symbolic multibody dynamics. The SymPy mechanics module now has enough power and functionality to be a fully featured symbolic dynamics module. The parser parses Autolev (version 4.1) code to SymPy code by making use of SymPy’s math libraries and the mechanics module.

The parser has been built using the ANTLR framework and its main purpose is to help former users of Autolev to get familiarized with multibody dynamics in SymPy.

The Plan:

The plan was to build a parser using ANTLR that could parse Autolev code to SymPy code. Overall, I think I was able to achieve most of what I had hoped for. I had faced some difficulties in some areas of the parser due to the very different nature of Autolev and Python. The parser has some issues as a result. I have specified all the details in the documentation I have written.

Work Done:

I made a parser for the Autolev language which is now a part of SymPy in the parsing module. I have written the code for the parser using the ANTLR framework. I have also included a bunch of tests for testing the rules of the parser code.

The majority of the work was a part of PR #14758. I made a second PR #15006 for the changes I had made after the main PR.

I have written documentation for the parser which is a part of these PRs: #15046, #15066 and #15067.

I have also written a PyDy for Autolev Users guide which is a part of PR #15077. This guide is meant to be a quick reference for looking up Autolev-PyDy equivalents.

Future Work:

  1. The parser has been built by referring to and parsing codes from the Autolev Tutorial and the book Dynamics Online: Theory and Implementation Using Autolev. Basically, the process involved going through each of these codes, validating the parser results and improving the rules if required to make sure the codes parsed well. As of now, a large number of codes of Dynamics Online have been parsed. These can be found in this GitLab repo. The repo is private because it contains proprietary files so you would have to request access to it. Completing all the remaining codes of the book would make the parser more complete.

  2. There are some limitations and issues with the parser and these have been discussed in the documentation. The plan is to fix these in order of priority.

  3. The parser is currently built using a kind of Concrete Syntax Tree (CST) using the ANTLR framework. It would be ideal to switch from a CST to an Abstract Syntax Tree (AST). This way, the parser code will be independent of the ANTLR grammar which makes it a lot more flexible. It would also be easier to make changes to the grammar and the rules of the parser.

I would like to keep contributing to SymPy. I would be doing a lot of math in college especially related to data science so I would love to contribute in areas like Probability and Algebra among others. I would also like to help newcomers feel comfortable with the environment.

Conclusion:

I would like to thank my mentors Ondřej Čertík and Jason Moore for believing in me and taking time out from their busy schedules to guide me throughout the project. I would also like to thank Aaron Meurer for looking over GSoC as the org admin and making sure that we all had a great experience working with SymPy.

Links:

Main PR: #14758

Updated parser code PR: #15006 and #15013

Documentation PRs: #15046, #15066 and #15067

PyDy for Autolev Users guide PR: #15077

Weekly Blog link: https://nkhlpappu.wordpress.com/

GitLab repo (Contains parsed Autolev codes which can be used as additional tests. Also contains the output comparison results.): https://gitlab.com/sympy/autolev-test-examples

Clone this wiki locally