antlr4
antlr4 copied to clipboard
ANLTR4 Pascal target for parsing Pascal Object Notation
I am looking for a Pascal ANTLR4 target for loading “Pascal Object Notation” into a running Pascal program, similar to how XML or JSON can be loaded into a Pascal program as DOM or a JavaScript object The plan is to provide a limited version of Pascal, and perhaps domain-specific namespaces that derive from a generic grammar.
I have found the Pascal Grammar, but now, how do I process Pascal Object Notation in Pascal? This requires a limited, domain specifiable parser written in Pascal.
The only think Google tells me about Pascal Object Notation is that this issue was opened :)
I think that you would need to expand on what you mean by that. But it sounds like a job for a hand crafted parser to be honest. If it is like JSON then it is fairly trivial. You may be able to adapt: https://www.getlazarus.org/json/
The chances of anyone writing a Pascal target for ANTLR are slim I am sorry to say.
If you don't wish to write a hand crafted parser, then you can use the Pascal version of lex and yacc, which I dare say will be perfectly adequate for your needs. https://wiki.freepascal.org/Plex_and_Pyacc
This isn't really an issue though, so perhaps you can close it?
I’ve already written an ANTLR4 grammar for C++ Object Notation (CPPON), https://github.com/coderextreme/CPPON , so something for a Pascal Object Notation is not too different. I will look into Plex and Pyacc.
There’s also the possibility that I write my own Pascal target for ANTLR4, but I realize Plex And Pyacc are better for Pascal. I’m thinking of the wider problem of developing Pascal Object Notation parsers for many languages.
Maybe an ANTLR4 grammar to Pyacc/Plex grammar translator would be more feasible?
For example, writing a Listener/Visitor for this grammar https://github.com/antlr/grammars-v4/tree/master/antlr/antlr4 to produce Plex/Pyacc grammar!
And thus, if there's an ANTLR4 grammar for Plex/Pyacc, how hard would it be to do a grammar to grammar translator, possibly using something like IntelliJ-MPS/VSCode/MapForce?
Here's an example of Pascal Object Notation (no loops, recursion or if/then): https://github.com/coderextreme/pascalsai/blob/main/code/JoeSkinTexcoordDisplacerKickUpdate2.inc
I found that chatgpt appears to convert ANTLR4 grammars to plex/pyacc grammars quite well, but I haven’t written any actions yet. At least it converted the ANTLR4 Grammar to some form of Pascal. I still need to download pyacc/plex, but I’ll do that tonight
Here's an example of Pascal Object Notation (no loops, recursion or if/then): https://github.com/coderextreme/pascalsai/blob/main/code/JoeSkinTexcoordDisplacerKickUpdate2.inc
If that is typical, then this is a trivial problem that would actually be made more complicated by using ANTLR. You just need a Readln and a few conditions.
It’s typically of HAnim. There are other aspects of X3D. Ideally, I could do a Pascal-based DSL. There’s around 300-400 classes to cover.