public static class ExistentialFrame {
THashSet<String> variables = new THashSet<String>(4);
ArrayList<Variable> blanks = new ArrayList<Variable>(2);
- boolean disallowNewExistentials;
+ public boolean disallowNewExistentials;
+
+ public EVariable createBlank(long location) {
+ Variable variable = new Variable("_");
+ blanks.add(variable);
+ EVariable result = new EVariable(variable);
+ result.location = location;
+ return result;
+ }
}
THashMap<String, Variable> variables = new THashMap<String, Variable>();
TIntArrayList chrConstraintFrames = new TIntArrayList();
ArrayList<CHRConstraintEntry> chrConstraintEntries = new ArrayList<CHRConstraintEntry>();
+ public CHRRuleset currentRuleset;
+
static class Entry {
String name;
Variable variable;
}
case '_': {
if(name.length()==1) {
- variable = new Variable("_");
ExistentialFrame existentialFrame = getCurrentExistentialFrame();
if(existentialFrame == null || existentialFrame.disallowNewExistentials) {
errorLog.log(location, "Blank variables can be used only in queries.");
return new EError(location);
}
- existentialFrame.blanks.add(variable);
- return new EVariable(variable);
+ return existentialFrame.createBlank(location);
}
break;
}
return null;
}
- private ExistentialFrame getCurrentExistentialFrame() {
+ public ExistentialFrame getCurrentExistentialFrame() {
int size = existentialFrames.size();
if(size == 0)
return null;
return existentialFrames.get(size-1);
}
- private Expression resolveFieldAccess(Expression base, int pos, String name) {
+ private Expression resolveFieldAccess(long location, Expression base, int pos, String name) {
while(pos != -1) {
int p = findSeparator(name, pos+1);
+ int endPos = p==-1 ? name.length() : p;
FieldAccessor accessor = new IdAccessor(
name.charAt(pos),
- name.substring(pos+1, p==-1 ? name.length() : p-1));
+ name.substring(pos+1, endPos));
+ accessor.location = Locations.sublocation(location, pos+1, endPos);
base = new EFieldAccess(base, accessor);
+ base.location = Locations.sublocation(location, 0, endPos);
pos = p;
}
return base;
if(begin == 0) {
Expression result = resolveLocalVariable(location, part);
if(result != null)
- return end == -1 ? result : resolveFieldAccess(result, end, name);
+ return end == -1 ? result : resolveFieldAccess(location, result, end, name);
// FIXME.. support for records
if(localEnvironment != null) {
if(result == null)
result = resolveValue(location, namespace, part);
if(result != null)
- return end == -1 ? result : resolveFieldAccess(result, end, name);
+ return end == -1 ? result : resolveFieldAccess(location, result, end, name);
}
reportResolveFailure(location, namespace, part);
return new EError(location);