Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Thoughts on parsing Mumps

72 views
Skip to first unread message

Kevin Toppenberg

unread,
Jan 22, 2025, 10:18:23 AMJan 22
to Everything MUMPS
I would like to have a mumps parser that I can control.  I want to use this for refactoring code, i.e. renaming variables (refactoring).  Simple search-and-replace would not be able to track the use of a particular variable safely enough for me to trust.   I understand that code in strings passed to XECUTE will be a pitfall.

I had previously written a crude parser that could extract calls out from a routine into other routines.  This let me track the inter-connections between files.  So I started trying to extend this code for more detailed parsing. But as I got deeper into code recursion, I realized that this problem must have been solved before.  So how to not reinvent the wheel?

I looked into YACC (yet-another-compiler-compiler), and learned that one needs a formal language definition, e.g. Bakus-Naur Form (BNF) or some variant (EBNF, ABFN).  And this is used in conjuction with a lexer that tokenizes source code. 

Again, I'm sure this has already been done.  Ed de Moel's link http://71.174.62.16/Demo/AnnoStd?Frame=Main&Page=a903001  seemed to have the core elements, spread out over several pages. 

I found think interesting link https://nvlpubs.nist.gov/nistpubs/Legacy/hb/nbshandbook118.pdf which is a 1975 publication from the National Bureau of Standards formal definition of Mumps.  It looks very similar to that found on Ed's site. 

I looked for a BNF repository, and found this(https://github.com/edhowland/BNF-Wiki/wiki) but it only has 2 languages!  This link (http://slebok.github.io/zoo/index.html) has more, but not mumps.   ANTLR (https://www.antlr3.org/works/) looks like a cool tool for working with many grammars, and helping find bugs in them.  Looks like it can automatically generate syntax diagrams too.  Cool!

Questions:

Are there any tools in this space for Mumps?
Anyone know of a BNF document for mumps?
Any other suggestions?

Kevin

K.S. Bhaskar

unread,
Jan 22, 2025, 11:03:22 AMJan 22
to Everything MUMPS
What about XINDEX? Also George James had a tool called Re/Parser, if I remember correctly.

Regards
– Bhaskar

ed de moel

unread,
Jan 22, 2025, 12:41:52 PMJan 22
to Everything MUMPS
On Wednesday, January 22, 2025 at 10:18:23 AM UTC-5 Kevin Toppenberg wrote:


That document is a draft for the 1977 ANSI standard. It should be almost identical to the 1977 version on the Annotated Standards pages.

Unfortunately, the Backus/Nauer format was not really formalized when the first attempts were done (1960s!)
to diagram the formalism for the M[UMPS] standard, so the "transition diagrams" follow a different
protocol.

As far as I know, nobody ever created a BNF rendition.

Hope this helps,
Ed
 

Maury Pepper

unread,
Jan 22, 2025, 9:05:50 PMJan 22
to everyth...@googlegroups.com
I recall (probably at an MDC meeting) hearing that MUMPS could not be defined using some formal languages. BNF could be one of those. Simply put, MUMPS syntax just doesn't fit.
--
You received this message because you are subscribed to the Google Groups "Everything MUMPS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to everythingmum...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/everythingmumps/d5438a86-a599-4f95-8f87-a3cbe6a597ddn%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kevin Toppenberg

unread,
Jan 26, 2025, 4:01:12 PMJan 26
to Everything MUMPS
Thanks for the input everyone.  I'm going to come back to this point later..

Kevin

Chris U

unread,
Jan 28, 2025, 2:00:55 AMJan 28
to Everything MUMPS

Greg Kreis

unread,
Jan 28, 2025, 8:31:01 AMJan 28
to everyth...@googlegroups.com

Would anyone be interested in pursuing a discussion of opensource AI models and their understanding of MUMPS?

If so, should be part of this thread or a new one?  I've been experimenting....

Message has been deleted

Dewey Hunt

unread,
Jan 29, 2025, 11:19:43 AMJan 29
to Everything MUMPS
Regarding MUMPS and AI. I trained openAI's o1 preview how to write M code for me. Given the top down fru-fru-free MUMPS syntax, o1 is actually really good at it. My basic process has been to upload multiple code examples and then ask the model to code something new. The context window is large enough to accommodate significant code examples and other relevant documentation. My major issue with the output is the white space formatting for new code lines. The model always uses all spaces and I prefer the tab character as the white space on new lines so when I cut/paste the code into Studio it formats correctly. I have also had excellent results asking o1 to convert code from other languages to MUMPS. The issue there, is most other popular languages don't have a similar feature to globals so this translation is best used as starter code. Also, o1 does not handle implementation specific I/O parameters well unless I had previously provided several examples in my example code.
Reply all
Reply to author
Forward
0 new messages