jmeaster30 / ocean

A C-like programming language (get it like sea-like like an ocean lol)
GNU General Public License v3.0
0 stars 0 forks source link

Proper multi file support #72

Closed jmeaster30 closed 11 months ago

jmeaster30 commented 11 months ago

each module will have a "using" statement for each module it uses. Module names should match the file path for the module so a module "std.io.print" would be in the file ./std/io/print.h2o

the "std" prefix will automatically look in the folder where the standard library is but all other modules will start to look in the current directory

jmeaster30 commented 11 months ago

This is going to be necessary for developing the standard library

jmeaster30 commented 11 months ago

I want to allow multiple modules in the same file. Also dots in a module name denote a folder/file change

std.io.print can resolve to either the "std.io.print" module in the file "std/io/print.h2o" or the "std.io.print" module in the file "std/io.h2o"

You can also reference modules with a slash like a file path and it acts identically to using dots.

If there is a module "really.awesome.module.in.a.deep.structure" but there is only a file called "really/awesome/module.h2o" then we will look there for the module.

starting a using path with "src" jumps to the top of the project's module path ie if you type out "ocean hydro-run project/main.h2o" then the top directory will be "./project" if you type out "ocean hydro-run" it defaults to 'main.h2o' in the current directory meaning the top directory is './'

jmeaster30 commented 11 months ago

How do we prioritize modules? My guts says pick the deepest one first because we would have to do more parsing to figure out if the higher level files even have the module.

It would be cool to combine the modules together but that feels really error prone

jmeaster30 commented 11 months ago

Multiple files works!!!!

jmeaster30 commented 11 months ago

Also standard library path defaults to the project root if it isn't defined