},
}
+class Symtable
+ def initialize
+ @builtins = BuiltinSyms
+ @scopes = [{}]
+ end
+
+ def []=(k,v)
+ @scopes.last[k] = v
+ end
+
+ def [](k)
+ (@scopes.map{|h| h[k] }.compact.last || BuiltinSyms[k])
+ end
+
+ def scope_start
+ @scopes.push({})
+ end
+
+ def scope_stop
+ @scopes.pop()
+ end
+end
+
class Lexer
Tok = Struct.new(:text, :file, :pos, :type)
SPACE = /([ \t\v\n\r]+|#.*\n)/
@declares = {}
@definitions = {}
add_file(path)
+ type_check
end
def add_file(path)
@definitions = parse.definitions()
end
- def add_files(paths)
- paths.each {|p| add_file(p) }
- end
-
def dump
pp({
name: @name,
defines: @definitions
})
end
+
+ def type_check
+ end
end
pkg = Package.new("example.src")