Skip to content

Commit ea85165

Browse files
committed
Fixed conversion of oidless single-dependent-empty-tuple atoms
1 parent 1c298d0 commit ea85165

File tree

8 files changed

+29
-2
lines changed

8 files changed

+29
-2
lines changed

PSOA2X/src/main/antlr3/org/ruleml/psoa/psoa2x/psoa2prolog/PrologConverter.g

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ tuple returns [boolean isDependent]
283283
DEPSIGN { $isDependent = $DEPSIGN.text.equals("+"); }
284284
(term { append(","); })*)
285285
{
286-
trimEnd(1);
286+
if (peekEnd(1).equals(",")) // Use trimEnd() only for trimming preceding comma, e.g. not for '(' in the conversion of p(+[])
287+
trimEnd(1);
287288
}
288289
;
289290

PSOA2X/src/main/antlr3/org/ruleml/psoa/psoa2x/psoa2tptp/TPTPConverter.g

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ tuple returns [boolean isDependent]
310310
DEPSIGN { $isDependent = $DEPSIGN.text.equals("+"); }
311311
(term { append(","); })*)
312312
{
313-
trimEnd(1);
313+
if (peekEnd(1).equals(",")) // Use trimEnd() only for trimming preceding comma, e.g. not for '(' in the conversion of p(+[])
314+
trimEnd(1);
314315
}
315316
;
316317

PSOA2X/src/main/java/org/ruleml/psoa/psoa2x/common/ANTLRBasedTranslator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ protected BufferIndex getBufferIndex()
177177
return index;
178178
}
179179

180+
protected String peekEnd(int len) {
181+
return m_buffer.substring(m_buffer.length() - len);
182+
}
183+
180184
protected void replace(BufferIndex startIndex, int offset, String s) {
181185
int end = startIndex.value + offset;
182186
m_buffer.replace(startIndex.value, end, s);

PSOATransRun/test/empty-tuples/empty-tuples-KB.psoa

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,22 @@ RuleML (
1919
o#p(+[] +[a] +[a b] +[a b c] -[] -[a] -[a b] -[a b c])
2020
)
2121
)
22+
r()
23+
r(+[])
24+
r(-[])
25+
r(a)
26+
r(+[a])
27+
r(-[a])
28+
r(a b)
29+
r(+[a b])
30+
r(-[a b])
31+
r(a b c)
32+
r(+[a b c])
33+
r(-[a b c])
34+
r(+[] +[a] +[a b] +[a b c] -[] -[a] -[a b] -[a b c])
35+
s(+[]) :-
36+
And(r(-[])
37+
r(+[] +[a] +[a b] +[a b c] -[] -[a] -[a b] -[a b c])
38+
)
2239
)
2340
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yes
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yes
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
And(r() r(+[]) r(-[]) r(+[a]) r(a) r(+[] +[a] -[] -[a]))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s(+[])

0 commit comments

Comments
 (0)