Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change parser package used #10

Closed
jClugstor opened this issue Feb 24, 2024 · 4 comments
Closed

Change parser package used #10

jClugstor opened this issue Feb 24, 2024 · 4 comments
Assignees

Comments

@jClugstor
Copy link
Member

jClugstor commented Feb 24, 2024

Automa.jl seems great for files that hold data, but I'm not sure it's the right tool for this. The way the parser is set up now means that there's a huge block of regex that's difficult to think about and difficult to change. It also can only handle a very small subset of the Base Modelica specification.

Ideally we would be using the Base Modelica ANTLR grammar with ANTLR to generate a parser that could handle everything in the specification. However ANTLR does not support Julia code generation.

There are a couple of alternatives I've been looking in to:

CombinedParsers.jl

This one has support for generating parsers from an EBNF grammar, which is similar to the grammar specification. However it hasn't been updated in 3 years and seems to not be working on Julia 1.10.

ParserCombinator.jl

This seems to be the one that most people use, and has been the most "maintained". Does not support

PikaParser.jl

Seems very simple to use, is a more recent package. Does not seem to support regex in matching, unless there's a work around. Would need to "translate" grammar in to something PikaParser understands.

Lerche.jl

A port of the Python Lark parser generator. Can take Lark grammars and generate a parser. Would need to create a Lark grammar from the ANTLR grammar.

ANTLR C++ / Python Code

Of course another option is to use ANTLR to generate C++ or Python code from the grammar for the parser and use it in this package. Not my favorite option, but definitely has some advantages.

@finmod
Copy link

finmod commented Feb 26, 2024

Can this be of help? https://github.com/OpenModelica/OMParser.jl together with the only effort I know to parse directly to MTK https://github.com/JKRT/OMBackend.jl/blob/master/src/CodeGeneration/MTK_CodeGeneration.jl

@ChrisRackauckas
Copy link
Member

I wouldn't use that, I'd directly use a BaseModelica parser since BaseModelica is much simpler than the full Modelica.

@jClugstor
Copy link
Member Author

Thanks, I might be able to get some use out of those. But yeah, full Modelica has several things that aren't valid in Base Modelica, which is supposed to make it simpler. So certain valid Modelica models should not parse as valid Base Modelica models.

@jClugstor jClugstor mentioned this issue Mar 11, 2024
@jClugstor
Copy link
Member Author

#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants