View
@@ -17,7 +17,10 @@
# Could move these to a dir like meta? From meta import id_kind? From meta
# import asdl?
from core import id_kind
#from osh import ast_ # TODO: could be ast_lib?
from osh import ast_
from asdl import py_meta
from core import util
class Id(object):
@@ -43,6 +46,11 @@ class Kind(object):
pass
class _AsdlModule(object):
"""Dummy object to copy attributes onto."""
pass
_ID_TO_KIND = {} # int -> Kind
def LookupKind(id_):
@@ -96,6 +104,27 @@ def IdInstance(i):
_kind_sizes = ID_SPEC.kind_sizes
#
# Instantiate the AST
#
f = util.GetResourceLoader().open('osh/osh.asdl')
_asdl_module, _type_lookup = ast_.LoadSchema(Id, f)
ast = _AsdlModule()
if 0:
py_meta.MakeTypes(_asdl_module, ast, _type_lookup)
else:
# Exported for the generated code to use
TYPE_LOOKUP = _type_lookup
# Get the types from elsewhere
from _devbuild.gen import osh_asdl
py_meta.AssignTypes(osh_asdl, ast)
f.close()
#
# Redirect Tables associated with IDs
#
@@ -125,7 +154,6 @@ def IdInstance(i):
def _InitRedirType():
# To break circular import. TODO: Id should really be metaprogrammed in the
# same module!
from osh import ast_ as ast
redir_type_e = ast.redir_type_e
return {
@@ -143,3 +171,5 @@ def _InitRedirType():
Id.Redir_TLess: redir_type_e.Here, # here word
# note: here docs aren't included
}
REDIR_TYPE = _InitRedirType()
View
@@ -18,7 +18,7 @@
from core import util
from osh import arith_parse
from osh import ast_ as ast
from osh.meta import ast
word_part_e = ast.word_part_e
word_e = ast.word_e
View
@@ -18,7 +18,7 @@
from core import test_lib
from core import word
from osh import ast_ as ast
from osh.meta import ast
from osh import ast_lib
from osh import parse_lib
from osh.word_parse import WordParser # module under test
View
@@ -54,7 +54,8 @@ replace() {
}
replace2() {
sed -r -i "s/^from core.id_kind import/from osh.meta import/g" */*.py
#sed -r -i "s/^from core.id_kind import/from osh.meta import/g" */*.py
sed -r -i "s/^from osh import ast_ as ast/from osh.meta import ast/g" */*.py
}
trailing-ws() {
View
@@ -12,7 +12,7 @@
from osh.meta import Id
from asdl import const
from osh import ast_ as ast
from osh.meta import ast
log = util.log