0

currently I am working on comparison between SICStus3 and SICStus4 but I got one issue that is SICStus4 will not consult any cases where the comment string has carriage controls or tab characters etc as given below.

Example case as given below.It has 3 arguments with comma delimiter.

case('pr_ua_sfochi',"
Response:
answer(amount(2370.09,usd),[[01AUG06SFO UA CHI Q9.30 1085.58FUA2SFS UA SFO Q9.30 1085.58FUA2SFS NUC2189.76END ROE1.0 XT USD 180.33 ZPSFOCHI 164.23US6.60ZP5.00AY XF4.50SFO4.5]],amount(2189.76,usd),amount(2189.76,usd),amount(180.33,usd),[[fua2sfs,fua2sfs]],amount(6.6,usd),amount(4.5,usd),amount(0.0,usd),amount(18.6,usd),lasttktdate([20061002]),lastdateafterres(200712282]),[[fic_ticketinfo(fare(fua2sfs),fic([]),nvb([]),nva([]),tktiss([]),penalty([]),tktendorsement([]),tourinfo([]),infomsgs([])),fic_ticketinfo(fare(fua2sfs),fic([]),nvb([]),nva([]),tktiss([]),penalty([]),tktendorsement([]),tourinfo([]),infomsgs([]))]],<>,<>,cat35(cat35info([])))
.
02/20/2006 17:05:10 Transaction 35 served by static.static.server1 (usclsefat002:7551) running E*Fare version $Name: build-2006-02-19-1900 $

",price(pnr(
        user('atl','1y',<>,<>,dept(<>,'0005300'),<>,<>,<>),
        [
                passenger(adt,1,[ptconly(n)])
        ],
        [

segment(1,sfo,chi,'ua','<>','100',20140901,0800,f,20140901,2100,'737',res(20140628,1316),hk,pf2(n,[],[],n),<>,flags(no,no,no,no,no,no,no,no,no)),

segment(2,chi,sfo,'ua','<>','101',20140906,1000,f,20140906,1400,'737',res(20140628,1316),hk,pf2(n,[],[],n),<>,flags(no,no,no,no,no,no,no,no,no))
        ]),[
                rebook(n),
                ticket(20140301,131659),
                dbaccess(20140301,131659),
                platingcarrier('ua'),
                tax_exempt([]),
                trapparm("trap:ffil"),
                city(y)
        ])).

The below predicate will remove comment section in above case.

flatten-cases :-
        getmessage(M1),
        write_flattened_case(M1),
        flatten-cases.
flatten-cases.
write_flattened_case(M1):-
        M1 = case(Case,_Comment,Entry),!,
        M2 = case(Case,Entry),
        writeq(M2),write('.'),nl.
getmessage(M) :-
        read(M),
        !,
        M \== end_of_file.
:- flatten-cases.

Now my requirement is to convert the comment string to an ASCII character list.

false
  • 10,264
  • 13
  • 101
  • 209
Ayyappa Boligala
  • 1,096
  • 7
  • 7
  • What version of SICStus 3 do you use? – false Jun 21 '16 at 09:51
  • There is no SP3-compatible parser in SP4 so the above can not be read into SP4 by any built-in functionality. One idea would be to use SP3 to parse it and then write it out from SP3 in a way that SP4 understands, e.g. using something like `read(X),write_canonical(X),write('.'),nl`. (PS. The code above defines a predicate `'-'` with two arguments, you probably want to name it `flatten_cases` instead.) – Per Mildner Jun 21 '16 at 10:43
  • 3.12.10 version is used SICStus 3.12.10patch1 (x86-linux-glibc2.3): Tue Nov 10 10:39:10 CET 2009 Licensed to eds.com | ?- – Ayyappa Boligala Jun 21 '16 at 11:46
  • @AyyappaBoligala: --- It seems you are in the transitioning phase from SICStus 3 to SICStus 4. So a new, better question would be better phrase: What is a workable transition from 3 to 4. – false Jun 21 '16 at 13:57

1 Answers1

2

Layout characters other than a regular space cannot occur literally in a quoted atom or a double quoted list. This is a requirement of the ISO standard and is fully implemented in SICStus since 3.9.0 invoking SICStus 3 with the option --iso. Since SICStus 4 only ISO syntax is supported.

You need to insert \n and \t accordingly. So instead of

log('Response:
    yes').     % BAD!

Now write

log('Response:\n\tyes').

Or, to make it better readable use a continuation escape sequence:

log('Response:\n\
\tyes').

Note that using literal tabs and literal newlines is highly problematic. On a printout you do not see them! Think of 'A \nB' which would not show the trailing spaces nor trailing tabs.

But there are also many other situations like: Making a screenshot of program text, making a photo of program text, using a 3270 terminal emulator and copying the output. In the past, punched cards. The text-mode when reading files (which was originally motivated by punched cards). Similar arguments hold for the tabulator which comes from typewriters with their manually settable tab stops.

And then on SO it is quite difficult to type in a TAB. The browser refuses to type it (very wisely), and if you copy it in, you get it rendered as spaces.


If I am at it, there is also another problem. The name flatten-case should rather be written flatten_case.

false
  • 10,264
  • 13
  • 101
  • 209