},
}
+Modules = {}
+
class Symtable
def initialize
@builtins = BuiltinSyms
@imports
end
- def definitions()
+ def definitions(api_only = false)
while !matches(:eof)
sym = {
export: accept("$"),
else
error("invalid symbol definition")
end
+ if api_only && sym[:export] then
+ sym[:value] = nil
+ end
@symbols[sym[:name]] = sym
end
@symbols
end
class Package
- def initialize(path)
+ attr_accessor :name, :definitions
+
+ def initialize(path, api_only = false)
@name = nil
@imports = {}
@declares = {}
@definitions = {}
- add_file(path)
+ add_file(path, api_only)
type_check
end
- def add_file(path)
+ def add_file(path, api_only = false)
parse = Parser.new(path)
@name = parse.module()
@imports = parse.imports()
-p @imports
- @definitions = parse.definitions()
+ @imports.each do |m|
+ pkg = Package.new("lib/#{m.downcase}.m", api_only = true)
+ Modules[pkg.name] = pkg.definitions()
+ end
+ @definitions = parse.definitions(api_only)
end
def dump
end
pkg = Package.new("lib/main.m")
+#pp Modules
#pkg.dump()