___ Posted July 27 Share Posted July 27 (edited) I'm writing a Weidu grammar for ANTLR4, a parser generator that supports multiple target languages. This means the grammar can be reused across Java, C#, or JavaScript code without any changes. At this point the grammar is "complete" in that generated parser it produces the same general results (ok/not ok) as Weidu for all .d, .tpa, .tpp, and .tp2 files I've tested. However, this doesn't necessarily mean the grammar is correct; it describes a similar but different language. Nevertheless, it should be usable for tasks like finding all declared variables or collecting a list of component groups. As a proof of concept, I've built a simple .d file visualizer: http://lapdu.s3-website.us-east-2.amazonaws.com/ . It does not do anything particularly interesting, just uses a parser generated from the grammar to build a dialog graph from provided .d files without need to read .dlg files. You can find the grammar here: https://gitlab.com/lapdu/lapdu-parser/-/tree/master/src/main/antlr4/imports. It is part of a Java project that is set up to generate and test Java parsers, but the grammar files themselves do not have any specific language dependencies, so you should be able to use them as is. Edited July 27 by ___ Quote Link to comment
mickabouille Posted July 27 Share Posted July 27 (edited) Oh I’ll have to taker a look at this, I sort of wanted to have this to extract some data fron tp2 without needing to exec weidu. But I couldn’t find à l'exercice and grammaire in an exploitable form in the weidu source and re-ing one seemed too big a task just for what is just some tinkering. Edited July 27 by mickabouille Quote Link to comment
paladin84 Posted July 27 Share Posted July 27 So the result of the web app should be some king of graph? I tried with one d file, it shows some graph, but it had many "undefined" nodes (as far as I understood where APPEND used in d file). With this file: https://github.com/Gibberlings3/BG1NPC/blob/master/bg1npc/phase2/dlg/x%23lp3rep.d from BG1NPC it shows nothing. Quote Link to comment
___ Posted July 27 Author Share Posted July 27 (edited) 47 minutes ago, paladin84 said: So the result of the web app should be some king of graph? I tried with one d file, it shows some graph, but it had many "undefined" nodes (as far as I understood where APPEND used in d file). With this file: https://github.com/Gibberlings3/BG1NPC/blob/master/bg1npc/phase2/dlg/x%23lp3rep.d from BG1NPC it shows nothing. Yeah, that thing is not something that I would call a production-level quality. I've fixed this particular error, but it is still incomplete(visualizer, not grammar) e.g. it does not handle COPY_TRANS or INTERJECT commands. Edited July 27 by ___ Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.