Coder Social home page Coder Social logo

m4j's Introduction

M4J - MUMPS for JAVA

An attempt at making a MUMPS runtime environment for the java virtual machine (JVM) similar to how other programming languages such as Groovy, Scala, Ruby, Python etc. have utilized the JVM platform

  • ANTLR-based Lexer/parser that can interpret and execute M code
  • Compiler that can compile M code to JVM byte-code (very early, only 1-2 commands implemented)
  • Globals API/proxy
    • Plain java persistence (Using H2's MVStore storage engine)
    • Connecters back to InterSystems Cache (Using cache extreme drivers)
  • Runtime environment (~40% of the system commands/functions implemented)
  • Shell/console tool including:
    • command history
    • TAB-expansion of variable and routine names
    • VI/EMACS-style key bindings

About

  • Created by Brian Bray, President/Founder of BrayLabs
  • Initially created as an exercise in learning M while working for the VA on the Health Management Platform (HMP). The original project, not the current eHMP project.
  • This is an enhanced version of what was originally published as open source software by the VA to OSEHRA,
  • Questions/comments can be directed to me via email, or I also still lurk on the Hardhats list a bit.

Prerequisites

  • Java (7 or 8)
  • Maven
  • InterSystems Cache (Optional)
  • ANTLR4 Eclipse Plugin (Optional)

Known issues

  • Currently will fail to fetch Cache dependencies, might need to comment them out or install into local maven repo manually
  • CacheGlobalStore doesn't work on OSX, the cache driver causes core dumps
  • There is still some quirky M code that the ANTLR grammar cannot handle
  • Not all the commands/system functions are implemented nor are they fully implemented and completely compatible
  • Some forms of indirection work, others do not

Quick start

git clone https://github.com/braylabs/m4j.git
cd m4j
mvn package

Quick Start - Launch M4J Console

java -jar target/m4j-0.1.jar
Welcome to M4J console, type 'H' to quit

M4J> S SAY="HELLO",NAME="WORLD"
M4J> W SAY_" "_NAME
HELLO WORLD
M4J>

Quick Start - M4J Compiler

Currently only 1 M routine in src/test/ compiles. This should generate a class file that can be utilized by regular java apps.

m4jc -package=m4j. -dest=target/m4jc/m4j src/test/java/com/braylabs/m4j/lang/M4JCTST.int

Quick Start - Java Code Example

import java.io.File;
import java.io.IOException;

import com.braylabs.m4j.lang.M4JRuntime;
import com.braylabs.m4j.lang.M4JRuntime.M4JProcess;
import com.braylabs.m4j.lang.RoutineProxy;
import com.braylabs.m4j.lang.RoutineProxy.MInterpRoutineProxy;
import com.braylabs.m4j.lang.RoutineProxy.JavaClassProxy.M4JEntryPoint;
import com.braylabs.m4j.lang.RoutineProxy.JavaClassProxy.M4JRoutine;

import static com.braylabs.m4j.lang.MUMPS.*;

public class Demo {
	public static void main(String[] args) throws IOException {
	  // Create a M4J runtime and register 2 routines:
	  // 1) Register an annotated java static method as a M routine
	  // 2) Load/Parse a M-language routine file from disk
		M4JRuntime runtime = new M4JRuntime();
		runtime.registerRoutine(new RoutineProxy.JavaClassProxy(MyFirstM4JRoutine.class));
		runtime.registerRoutine(new MInterpRoutineProxy(new File("src/main/mumps/XLFSTR.int")));
		
		// Create a M4J Process and evaluate a simple line
		M4JProcess proc = new M4JProcess(runtime, 123);
		proc.getInterpreter().evalLine("W !,$$SAY^HELLO($$UP^XLFSTR(\"world\")),!");
	}

	// Register this class as a M routine named 'HELLO'
	@M4JRoutine(name="HELLO")
	public static class MyFirstM4JRoutine {
		
		// With an entry point named 'SAY'
		@M4JEntryPoint(name="SAY")
		public static String hello(String val) {
			return "Hello: " + val;
		}
	}
}

m4j's People

Contributors

bbray avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

m4j's Issues

Build failure with Maven for H2 global store

Hello,
I am currently trying to compile the system using Maven. After commenting out the references to the Cache dependency, and removing that dependency within the pom.xml file, I am getting this error related to the H2 global store:

[ERROR] /home/seth/Desktop/m4j/src/main/java/com/braylabs/m4j/global/GlobalStore.java:[51,49] cannot find symbol
  symbol:   method removeMap()
  location: class org.h2.mvstore.MVMap<java.lang.Object,java.lang.Object>
[ERROR] /home/seth/Desktop/m4j/src/main/java/com/braylabs/m4j/global/MMap.java:[286,39] wrong number of type arguments; required 2
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.197 s
[INFO] Finished at: 2022-04-24T20:08:08-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project m4j: Compilation failure: Compilation failure: 
[ERROR] /home/seth/Desktop/m4j/src/main/java/com/braylabs/m4j/global/GlobalStore.java:[51,49] cannot find symbol
[ERROR]   symbol:   method removeMap()
[ERROR]   location: class org.h2.mvstore.MVMap<java.lang.Object,java.lang.Object>
[ERROR] /home/seth/Desktop/m4j/src/main/java/com/braylabs/m4j/global/MMap.java:[286,39] wrong number of type arguments; required 2

Would there be a specific value that I would need to set for the 2nd argument?
Thank you!
-Seth

The project is active?

Hello Brian,

I work in a Brazilian software company that develops ERP in MUMPS.
It is a very large system, a year that was converted from the MUMPS Intersystems for GTM. Also recreated some implementations connectors and Java tools to maintain compatibility with Intersystems.
Currently the company is in a process of changing everything to java and I enjoyed your M4J project.
The project is active?

Thank you

Missing classes in git

Hello,

The class MUMPS2ParserBaseVisitor and MUMPSBaseVisitor not found in git

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.