/eomc

experimental optimizing MeTTa compiler

Primary LanguagePrologMIT LicenseMIT

experimental optimizing MeTTa compiler.

Compiles MeTTa to a target language which is prolog. The target language output is slightly optimized.

how to install

install swi-prolog dependencies by running the prolog and confirming everything with "yes"

swipl ./INSTALL.prolog

how to run

source source code is read from PATHTOFILE

basic running

./eomc.sh PATHTOFILE

running with dumping generated code to terminal

./eomc.sh PATHTOFILE   && echo "" && cat generated0.prolog

running with dumping generated code to terminal and executing generated program with swi-prolog

./eomc.sh PATHTOFILE   && cat generated0.prolog     && swipl -s generated0.prolog -g entry0 -g halt

basic source code examples

(= (exampleFunctionA)  (*  (+ 2.2 3) 6) )

limitations / assumptions

  • compiler: there is virtually no semantics checking. The code has to be sematically correct so that the compiler produces correct output.
  • lexer : the lexeer doesn't parse anything with *, - etc. correctly. so let2 has to be used instead of let* etc. for now.
  • runtime: there is only a minimal stdlib implemented.
  • only the simplistic bare minimal features of the language are supported for now. That means no case and implementation of interpreterm etc.

support table of compiler+libraries

feature parser backend
datatype:boolean yes yes
datatype:int yes yes
datatype:float yes yes
function declaration full full
function invocation yes yes
variable definition/usage yes yes
control flow: conditionals yes yes
control flow: sequential - yes
data flow: let yes yes
datastructure declaration yes yes
datastructure unification - (yes)
feature parser runtime
basic math (+, *, etc.) - yes
basic math (cos, etc.) - (yes)
comparison - yes
collapse function - yes
superpose function - yes
match function - no
call into python - no

supported Prolog environments

for the compiler swi-prolog is supported. Backend swi-prolog is supported and recommended. Other Prolog environments such as GNU-prolog could also work.

stable versions

here are version which are relativly stable

https://github.com/PtrMan/eomc/tree/06117da9455c63629806f015f1e8dd94cbe39e54 from 07-28-2025 . no known issues