izuzanak / uclang

Interpreted, dynamically typed, object-oriented programming language
GNU General Public License v2.0
23 stars 3 forks source link

Missing import 'regex' in 'uclang/demos/imx_sdma/assembler.ucl' #2

Open mingodad opened 3 years ago

mingodad commented 3 years ago

Testing this project and trying to execute 'uclang/demos/imx_sdma/main.ucl' I'm getting this error message:

uclang main.ucl
 ---------------------------------------- 
1. ERROR: in file: "./assembler.ucl" on line: 57
      [ new Regex("^ *$"), 0x0000, m_ignore_cb ],

Class name Regex cannot be resolved
 ---------------------------------------- 

And after adding 'import regex;' to 'uclang/demos/imx_sdma/assembler.ucl' no error reported.

Another issue I'm having when trying to execute 'uclang/examples/*' directly it doesn't due to not having the 'export UCLANG_MODS_PATH=' set and it doesn't seem that we can us import with relative paths.

izuzanak commented 3 years ago

Class Regex was historically part of module sys, from which it was removed to separated module regex. Demo example was not fixed from since then. Fixed in (e246ee9c0304c2a28641054cb25a0c5641dd515b). Thank you for noticing.

izuzanak commented 3 years ago

There are three sources of directories to be searched for modules:

  1. Default directories: . and modules.
  2. Command line argument -mods=. Argument should precede name of script and should contain directories separated by colon. Eg. -mods=DIR1:DIR2:DIR3.
  3. Environment variable UCLANG_MODS_PATH, containing directories separated by colon. Eg. export UCLANG_MODS_PATH=DIR1:DIR2:DIR3

In both cases directories can be absolute or relative.

mingodad commented 3 years ago

Thank you for reply !

Would be nice if that information could be available from command line like uclang -h or uclang --help.

When I mentioned about relative path for import I was meaning something like import ../tutorial;.

izuzanak commented 3 years ago

I will occasionally add --help argument, and also change existing arguments from some weird combination of short/long version eg. -mods to long version eg. --mods.

You are right, module to be imported is identified just by its name (identifier). Module implementation is looked for in module directories mentioned in previous comment.