bugGNU Prolog for Java - Bugs: bug #38828, Infix expressions with...


bug #38828: Infix expressions with user-defined operators

Submitted by:  Carlos-Manuel LÓPEZ-ENRÍQUEZ <lopencarma>
Submitted on:  Thu 25 Apr 2013 03:18:41 PM UTC  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: OpenPlanned Release: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Thu 25 Apr 2013 03:18:41 PM UTC, original submission:

I used gnu-prolog to create a program. For syntax purposes I defined an operator '::' (i.e, op(350,xfy,::)) in order to make infix expressions such as A=a::b::c

Now I want to use gnu prolog for java (0.2.6) and I defined the same operator in my environment:


Nevertheless, the infix syntax A=a::b::c is not allowed.


I'm loading the following prolog program:


1 rename([]):-!.
2 rename([_::_|Tail]):-!, %the api already exists
3 rename(Tail).
4 rename([S::M as Alias| Tail]):-
5 api(S::M,Bounded,Free),!,
6 assertz(dataset(Alias,Bounded,Free)),
7 rename(Tail).

In my java code I'm defining the '::' operator in the environment (along with the operator 'as'):

this.environment = new Environment();
this.interpreter = this.environment.createInterpreter();

Then I load the <rename.pl> program with the code:

for(int i= 0; i < plFileNames.length; i++){
Log.d("Loading '"+plFileNames[i].trim()+"'");

List<PrologTextLoaderError> list = environment.getLoadingErrors();
Iterator<PrologTextLoaderError> iterator = list.iterator();
int j=0;
PrologTextLoaderError p_error = iterator.next();

Then I get the error messages:

[13.04.25 10:12:43:140] Loading '/Users/aguacatin/Research/HADAS/PhD/Prolog/qw_activity_derivation/rename.pl'
[13.04.25 10:12:43:142] 1 syntax error: Encountered "::" at line 2, column 10.
[13.04.25 10:12:43:142] Was expecting one of:
[13.04.25 10:12:43:142] <CLOSE_LIST_TOKEN> ...
[13.04.25 10:12:43:142] <COMMA_TOKEN> ...
[13.04.25 10:12:43:142] <HEAD_TAIL_SEPARATOR_TOKEN> ...
[13.04.25 10:12:43:142]
[13.04.25 10:12:43:143] 2 syntax error: Encountered "::" at line 4, column 10.
[13.04.25 10:12:43:143] Was expecting one of:
[13.04.25 10:12:43:143] <CLOSE_LIST_TOKEN> ...
[13.04.25 10:12:43:143] <COMMA_TOKEN> ...
[13.04.25 10:12:43:143] <HEAD_TAIL_SEPARATOR_TOKEN> ...
[13.04.25 10:12:43:143]
[13.04.25 10:12:43:143] GENERATING: "hsql2_2([whatulike::interests as a, whatulike::interests as b],[a::nickname='Alice', b::nickname='Bob', a::interests::interest::tag=b::interests::interest::tag],[ b::nickname, b::interests])."
gnu.prolog.io.ParseException: Encountered "." at line 1, column 192.
Was expecting:

at gnu.prolog.io.TermReader.readTermEof(TermReader.java:87)
at gnu.prolog.io.TermReader.stringToTerm(TermReader.java:69)
at QWDerivationWrapper.generate(QWDerivationWrapper.java:123)
at QWDerivationWrapper.main(QWDerivationWrapper.java:324)
Exception in thread "main" java.lang.NullPointerException
at QWDerivationWrapper.generate(QWDerivationWrapper.java:128)
at QWDerivationWrapper.main(QWDerivationWrapper.java:324)

Another attempt defining 'op(350,xfy,::)'…

try {
Term double_colon_op_term = TermReader.stringToTerm("op(350,xfy,::)", this.environment);
} catch (ParseException e) {
// TODO Auto-generated catch block
} catch (PrologException e) {
// TODO Auto-generated catch block

but I get the same error messages <errors>.

Carlos-Manuel LÓPEZ-ENRÍQUEZ <lopencarma>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #27939:  rename.pl added by lopencarma (192B - text/x-perl-script)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by lopencarma (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 25 Apr 2013 03:18:41 PM UTClopencarmaAttached File-=>Added rename.pl, #27939

    Back to the top

    Powered by Savane 3.1-cleanup