asked
Jan 09
Hossein 81 ● 8 ● 20 Consider this file:
module Loader
import ParseTree;
import AbstractSyntaxes;
import ConcreteSyntaxes;
import Parser;
data IntermediateHeap = nheap(str name, list[Binding] bs)
| uheap(str name, IntermediateHeap h, list[Binding] ebs);
public Heap to_heap(nheap(n, bs)) = norm_heap(n, (b.name: b.exp | b <- bs));
public Heap to_heap(uheap(n, ih, ebs)) = union_heap(n, to_heap(ih), (b.name: b.exp | b <- ebs));
public AbstractSyntaxes::Heap implode(ConcreteSyntaxes::Heap h) =
to_heap(implode(#IntermediateHeap, h));
public AbstractSyntaxes::Heap load_heap(loc l) = implode(parse_heap(l));
Regardless of what the contents of my other files are, the constructor IntermediateHeap is visibly present here in this very file. Despite that, I get the following very strange load error:
rascal>load_heap(heaps_file);
project://Launch2/src/Loader.rsc:16,9: IllegalArgument(..., "Cannot find a constructor IntermediateHeap")
stacktrace:
somewhere in: public org.eclipse.imp.pdb.facts.IValue org.rascalmpl.library.ParseTree.implode(org.eclipse.imp.pdb.facts.IConstructor,org.eclipse.imp.pdb.facts.IConstructor)
somewhere in: implode
somewhere in: load_heap
somewhere in: $shell$
Any ideas at all? (Sorry the full error message didn't seem to fit reasonably in this posting. Let me know if you're interested and I'll see how I can coerce it...)
Here is my concrete syntax:
module ConcreteSyntaxes
lexical Ident = [a-zA-Z][a-zA-Z0-9]* !>> [a-zA-Z0-9];
lexical LAYOUT = [\t-\n\r\ ];
layout LAYOUTLIST = LAYOUT* !>> [\t-\n\r\ ] ;
start syntax Heap = norm_heap: Ident "=" "{" {HeapBinding ","}* "}"
| union_heap: Ident "=" "(" Ident "," {HeapBinding ","}* ")";
syntax HeapBinding = bind: Ident "|-\>" Exp;
syntax Exp = var: Ident
| lam: "\\" Ident "." Exp
| app: Exp Ident
| bracket "(" Exp ")"
| let: "let" {Binding ","}* "in" Exp;
syntax Binding = binding: Ident "=" Exp;