Skip to content

Commit

Permalink
asdl_cpp: port changes from LFortran
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Aug 4, 2022
1 parent ead3e00 commit b16ca1a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions grammar/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,11 @@ def visitConstructor(self, cons, _):
self.emit( 'Location loc;', 2)
self.emit( 'loc.first = self().read_int64();', 2)
self.emit( 'loc.last = self().read_int64();', 2)
if subs["lcompiler"] == "lfortran":
# Set the location to 0 for now, since we do not yet
# support multiple files
self.emit( 'loc.first = 0;', 2)
self.emit( 'loc.last = 0;', 2)
for line in lines:
self.emit(line, 2)
self.emit( 'return %s::make_%s_t(%s);' % (subs["MOD"], name, ", ".join(args)), 2)
Expand Down Expand Up @@ -2143,11 +2148,6 @@ def add_masks(fields, node):
def main(argv):
if len(argv) == 3:
def_file, out_file = argv[1:]
elif len(argv) == 1:
print("Assuming default values of AST.asdl and ast.h")
here = os.path.dirname(__file__)
def_file = os.path.join(here, "AST.asdl")
out_file = os.path.join(here, "..", "src", "lpython", "ast.h")
else:
print("invalid arguments")
return 2
Expand All @@ -2165,6 +2165,9 @@ def main(argv):
if subs["MOD"] == "LPYTHON":
subs["MOD"] = "LPython::AST"
subs["mod"] = "ast"
subs["lcompiler"] = "lpython"
else:
subs["lcompiler"] = "lfortran"
is_asr = (mod.name.upper() == "ASR")
fp = open(out_file, "w", encoding="utf-8")
try:
Expand Down

0 comments on commit b16ca1a

Please sign in to comment.