📄 parser.java
字号:
while (i.hasNext()) {
Slot slot = (Slot) i.next();
Slot inverseSlot = (Slot) itsInverseSlotMap.get(slot);
slot.setInverseSlot(inverseSlot);
}
}
private void connectSuperslots() {
Iterator i = itsSuperslotsMap.keySet().iterator();
while (i.hasNext()) {
Slot slot = (Slot) i.next();
Collection superslots = (Collection) itsSuperslotsMap.get(slot);
connectSuperslots(slot, superslots);
}
}
private void connectSuperslots(Slot slot, Collection superslots) {
Iterator i = superslots.iterator();
while (i.hasNext()) {
String name = (String) i.next();
Slot superslot = itsKB.getSlot(name);
slot.addDirectSuperslot(superslot);
}
}
private Facet getOrCreateFacet(String facetName) {
Facet facet = itsKB.getFacet(facetName);
if (facet == null) {
facet = itsKB.createFacet(facetName, itsKB.getDefaultFacetMetaCls(), false);
}
return facet;
}
private Map clsToSlotToValueType = new HashMap();
private ValueType getOwnSlotValueType(Instance instance, Collection directTypes, Slot slot) {
ValueType valueType;
if (directTypes.size() == 1) {
Cls type = (Cls) CollectionUtilities.getFirstItem(directTypes);
Map slotToValueType = (Map) clsToSlotToValueType.get(type);
if (slotToValueType == null) {
slotToValueType = new HashMap();
clsToSlotToValueType.put(type, slotToValueType);
}
valueType = (ValueType) slotToValueType.get(slot);
if (valueType == null) {
valueType = instance.getOwnSlotValueType(slot);
slotToValueType.put(slot, valueType);
}
} else {
valueType = instance.getOwnSlotValueType(slot);
}
return valueType;
}
// --------------------------------------------------------------------------------------
final public void accessFacet(Cls cls, Slot slot) throws ParseException {
jj_consume_token(ACCESS);
switch (jj_nt.kind) {
case READ_WRITE:
jj_consume_token(READ_WRITE);
break;
case READ_ONLY:
jj_consume_token(READ_ONLY);
break;
case INITIALIZER_ONLY:
jj_consume_token(INITIALIZER_ONLY);
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
final public void allowedClassesValueDescription(Cls cls, Slot slot) throws ParseException {
Collection clses;
jj_consume_token(ALLOWED_CLASSES);
clses = clsesList();
if (cls == null) {
slot.setAllowedClses(clses);
} else {
cls.setTemplateSlotAllowedClses(slot, clses);
}
}
final public void allowedConstantValueDescription(Cls cls, Slot slot) throws ParseException {
switch (jj_nt.kind) {
case ALLOWED_FLOATS:
allowedFloatsValueDescription(cls, slot);
break;
case ALLOWED_INTEGERS:
allowedIntegersValueDescription(cls, slot);
break;
case ALLOWED_SYMBOLS:
allowedSymbolsValueDescription(cls, slot);
break;
case ALLOWED_STRINGS:
allowedStringsValueDescription(cls, slot);
break;
case ALLOWED_VALUES:
allowedValuesValueDescription(cls, slot);
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
final public void allowedConstantValueDescriptionExtension(Cls cls, Slot slot) throws ParseException {
switch (jj_nt.kind) {
case ALLOWED_CLASSES:
allowedClassesValueDescription(cls, slot);
break;
case ALLOWED_GRAMMAR:
allowedGrammarValueDescription(cls, slot);
break;
case ALLOWED_PARENTS:
allowedParentsValueDescription(cls, slot);
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
final public void allowedFloatsValueDescription(Cls cls, Slot slot) throws ParseException {
String s;
List list = new ArrayList();
jj_consume_token(ALLOWED_FLOATS);
label_1:
while (true) {
s = symbol();
list.add(s);
switch (jj_nt.kind) {
case ABSTRACT:
case ACCESS:
case ALLOWED_CLASSES:
case ALLOWED_FLOATS:
case ALLOWED_GRAMMAR:
case ALLOWED_INTEGERS:
case ALLOWED_PARENTS:
case ALLOWED_STRINGS:
case ALLOWED_SYMBOLS:
case ALLOWED_VALUES:
case ANY:
case ASSOCIATED_FACET:
case BUILD:
case CARDINALITY:
case COMMENT:
case COMPOSITE:
case CONCRETE:
case CREATE_ACCESSOR:
case DEFAULT_:
case DEFCLASS:
case EXCLUSIVE:
case FLOAT:
case INCLUDE:
case INHERIT:
case INITIALIZER_ONLY:
case INSTANCE:
case INTEGER:
case INVERSE_SLOT:
case IS_A:
case LOCAL:
case MULTISLOT:
case NO_INHERIT:
case NON_REACTIVE:
case NOTE:
case OF:
case OVERRIDE_MESSAGE:
case PATTERN_MATCH:
case PRIVATE:
case PROPAGATION:
case PUBLIC:
case RANGE:
case REACTIVE:
case READ:
case READ_ONLY:
case READ_WRITE:
case ROLE:
case SINGLE_SLOT:
case SHARED:
case SLOT:
case SOURCE:
case STORAGE:
case STRING:
case SUBSLOT_OF:
case SYMBOL:
case TYPE:
case USER_FACET:
case VALUE:
case VISIBILITY:
case VERSION:
case WRITE:
case SYMBOL_LITERAL:
;
break;
default:
jj_la1[3] = jj_gen;
break label_1;
}
}
}
final public void allowedGrammarValueDescription(Cls cls, Slot slot) throws ParseException {
jj_consume_token(ALLOWED_GRAMMAR);
string();
switch (jj_nt.kind) {
case STRING_LITERAL:
string();
break;
default:
jj_la1[4] = jj_gen;
;
}
}
final public void allowedIntegersValueDescription(Cls cls, Slot slot) throws ParseException {
String s;
List list = new ArrayList();
jj_consume_token(ALLOWED_INTEGERS);
label_2:
while (true) {
s = symbol();
list.add(s);
switch (jj_nt.kind) {
case ABSTRACT:
case ACCESS:
case ALLOWED_CLASSES:
case ALLOWED_FLOATS:
case ALLOWED_GRAMMAR:
case ALLOWED_INTEGERS:
case ALLOWED_PARENTS:
case ALLOWED_STRINGS:
case ALLOWED_SYMBOLS:
case ALLOWED_VALUES:
case ANY:
case ASSOCIATED_FACET:
case BUILD:
case CARDINALITY:
case COMMENT:
case COMPOSITE:
case CONCRETE:
case CREATE_ACCESSOR:
case DEFAULT_:
case DEFCLASS:
case EXCLUSIVE:
case FLOAT:
case INCLUDE:
case INHERIT:
case INITIALIZER_ONLY:
case INSTANCE:
case INTEGER:
case INVERSE_SLOT:
case IS_A:
case LOCAL:
case MULTISLOT:
case NO_INHERIT:
case NON_REACTIVE:
case NOTE:
case OF:
case OVERRIDE_MESSAGE:
case PATTERN_MATCH:
case PRIVATE:
case PROPAGATION:
case PUBLIC:
case RANGE:
case REACTIVE:
case READ:
case READ_ONLY:
case READ_WRITE:
case ROLE:
case SINGLE_SLOT:
case SHARED:
case SLOT:
case SOURCE:
case STORAGE:
case STRING:
case SUBSLOT_OF:
case SYMBOL:
case TYPE:
case USER_FACET:
case VALUE:
case VISIBILITY:
case VERSION:
case WRITE:
case SYMBOL_LITERAL:
;
break;
default:
jj_la1[5] = jj_gen;
break label_2;
}
}
}
final public void allowedParentsValueDescription(Cls cls, Slot slot) throws ParseException {
Collection parents;
jj_consume_token(ALLOWED_PARENTS);
parents = clsesList();
if (cls == null) {
slot.setAllowedParents(parents);
} else {
cls.setTemplateSlotAllowedParents(slot, parents);
}
}
final public void allowedStringsValueDescription(Cls cls, Slot slot) throws ParseException {
String s;
List list = new ArrayList();
jj_consume_token(ALLOWED_STRINGS);
label_3:
while (true) {
s = string();
list.add(s);
switch (jj_nt.kind) {
case STRING_LITERAL:
;
break;
default:
jj_la1[6] = jj_gen;
break label_3;
}
}
if (cls == null) {
slot.setAllowedValues(list);
} else {
cls.setTemplateSlotAllowedValues(slot, list);
}
}
final public void allowedSymbolsValueDescription(Cls cls, Slot slot) throws ParseException {
String s;
List list = new ArrayList();
jj_consume_token(ALLOWED_SYMBOLS);
label_4:
while (true) {
s = symbol();
list.add(s);
switch (jj_nt.kind) {
case ABSTRACT:
case ACCESS:
case ALLOWED_CLASSES:
case ALLOWED_FLOATS:
case ALLOWED_GRAMMAR:
case ALLOWED_INTEGERS:
case ALLOWED_PARENTS:
case ALLOWED_STRINGS:
case ALLOWED_SYMBOLS:
case ALLOWED_VALUES:
case ANY:
case ASSOCIATED_FACET:
case BUILD:
case CARDINALITY:
case COMMENT:
case COMPOSITE:
case CONCRETE:
case CREATE_ACCESSOR:
case DEFAULT_:
case DEFCLASS:
case EXCLUSIVE:
case FLOAT:
case INCLUDE:
case INHERIT:
case INITIALIZER_ONLY:
case INSTANCE:
case INTEGER:
case INVERSE_SLOT:
case IS_A:
case LOCAL:
case MULTISLOT:
case NO_INHERIT:
case NON_REACTIVE:
case NOTE:
case OF:
case OVERRIDE_MESSAGE:
case PATTERN_MATCH:
case PRIVATE:
case PROPAGATION:
case PUBLIC:
case RANGE:
case REACTIVE:
case READ:
case READ_ONLY:
case READ_WRITE:
case ROLE:
case SINGLE_SLOT:
case SHARED:
case SLOT:
case SOURCE:
case STORAGE:
case STRING:
case SUBSLOT_OF:
case SYMBOL:
case TYPE:
case USER_FACET:
case VALUE:
case VISIBILITY:
case VERSION:
case WRITE:
case SYMBOL_LITERAL:
;
break;
default:
jj_la1[7] = jj_gen;
break label_4;
}
}
if (cls == null) {
slot.setAllowedValues(list);
} else {
cls.setTemplateSlotAllowedValues(slot, list);
}
}
final public void allowedValuesValueDescription(Cls cls, Slot slot) throws ParseException {
List list;
jj_consume_token(ALLOWED_VALUES);
list = constants();
checkBooleanAndSetValues(cls, slot, list);
}
final public void cardinalityValueDescription(Cls cls, Slot slot) throws ParseException {
String minString;
String maxString;
jj_consume_token(CARDINALITY);
minString = symbol();
maxString = symbol();
Integer min = toInteger(minString);
if (min != null && min.intValue() != 0) {
if (cls == null) {
slot.setMinimumCardinality(min.intValue());
} else {
cls.setTemplateSlotMinimumCardinality(slot, min.intValue());
}
}
Integer max = toInteger(maxString);
if (max != null) {
if (cls == null) {
slot.setMaximumCardinality(max.intValue());
} else {
cls.setTemplateSlotMaximumCardinality(slot, max.intValue());
}
}
}
final public void cls() throws ParseException {
Cls cls;
String name;
String comment = null;
Collection parents;
try {
jj_consume_token(LPAREN);
jj_consume_token(DEFCLASS);
name = symbol();
switch (jj_nt.kind) {
case STRING_LITERAL:
comment = string();
break;
default:
jj_la1[8] = jj_gen;
;
}
jj_consume_token(LPAREN);
jj_consume_token(IS_A);
parents = clsesList();
jj_consume_token(RPAREN);
cls=getCls(name, comment, parents, true);
clsRole(cls);
label_5:
while (true) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -