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


bug #38828: Infix expressions with user-defined operators

Submitter:  Carlos-Manuel LÓPEZ-ENRÍQUEZ <lopencarma>
Submitted:  Thu 25 Apr 2013 03:18:41 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

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:
    <CLOSE_TOKEN> ...
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 Files:

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
  • -email is unavailable- added by lopencarma (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-04-25 lopencarma Attached File- Added rename.pl, #27939

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code