progranet/OMeta.Lua

It seems that a global variable OMeta is required but not documented

Opened this issue · 1 comments

Testing this project I noticed that for the examples to work properly we need to declare a global variable OMeta instead of local when using it see bellow:

--local OMeta = require 'ometa'
OMeta = require 'ometa' --!!! instead of a local it seems we need a global here for the examples to work
local Calc = OMeta.doFile('calc.lpp') -- a name of a file containing the TableTreeCalc package
local tree = Calc.exp:matchString('2*(5+6)')

Thank you for your great work !

Or alternatively some grammar examples should have a local variable OMeta at the top of the grammars:

local OMeta = require 'ometa' --!!! we need this declaration because the generated code assume OMeta is in scope

local ometa TableTreeCalc merges require'grammar_commons' {
  exp     = addexp,
  addexp  = l:addexp '+' r:mulexp   [{'+', l, r}] 
          | l:addexp '-' r:mulexp   [{'-', l, r}] 
          | mulexp
          , 
  mulexp  = l:mulexp '*' r:primexp  [{'*', l, r}] 
          | l:mulexp '/' r:primexp  [{'/', l, r}] 
          | primexp
          , 
  primexp = '(' $^:exp ')'
          | numstr
          , 
  numstr  = toNumber(<'-'? digit+>)
} 
return TableTreeCalc