patscc-pp

151 views
Skip to first unread message

gmhwxi

unread,
May 17, 2015, 5:02:47 PM5/17/15
to ats-lan...@googlegroups.com

Error messages issued by the typechecker of ATS containing strings representing
abstract syntax trees. Such messages can be very informative but are difficult to parse
(especially for beginners).

This thread is meant for people to discuss how "translators" can be written so as to
make ATS error messages easier to access.

Yannick Duchêne

unread,
May 17, 2015, 5:32:03 PM5/17/15
to ats-lan...@googlegroups.com
In another thread, a question raised: wrapper or pipe filter?

What abut a mix of both? Modular using pipe filters? The wrapper would manage pipes.

Filters are nice in that they follow the Unix principle: do one thing correctly. But they needs to be applied using pipes, and pipes are not so nice: you lose the exit code of the main program (the exit code is the one of the filter instead) and you have to handle stdout and stderr separately. This ends to require the use of temporary file and multiple redirection to and from temporary files.

The wrapper could handle all of the bad aspects of pipes while still relying and simple and technology neutral filters?

Brandon Barker

unread,
May 17, 2015, 6:01:20 PM5/17/15
to ats-lang-users
I think this will certainly be great for new users and hopefully
others as well. A "filter" has the advantage of not changing the
default but having something immediately available to new users (if
they know about it, which I guess is the next best thing to a
default).

Another possibility:

A web form that you can copy and paste an error from patscc in and
choose various output/analysis options. Aside from pretty printing, it
could possibly consult a database of errors and solutions/commentary.
Of course, it would be great if these could be pulled from this
discussion group.
> --
> You received this message because you are subscribed to the Google Groups
> "ats-lang-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ats-lang-user...@googlegroups.com.
> To post to this group, send email to ats-lan...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/44e17e03-4604-4f5c-8392-372434de61be%40googlegroups.com.



--
Brandon Barker
brandon...@gmail.com

Yannick Duchêne

unread,
May 17, 2015, 6:12:08 PM5/17/15
to ats-lan...@googlegroups.com


Le lundi 18 mai 2015 00:01:20 UTC+2, Brandon Barker a écrit :
I think this will certainly be great for new users and hopefully
others as well. A "filter" has the advantage of not changing the
default but having something immediately available to new users (if
they know about it, which I guess is the next best thing to a
default).

**Another possibility: **


A web form that you can copy and paste an error from patscc in and
choose various output/analysis options. Aside from pretty printing, it
could possibly consult a database of errors and solutions/commentary.
Of course, it would be great if these could be pulled from this
discussion group.


Or rather additionally. These are two different things and opting for one can't exclude the other.
 
I will turn the filter I already made, into a wrapper, tomorrow. But this will be Python, not ATS and this will not be a general wrapper as I described, just this one filter turned into a wrapper.

Yannick Duchêne

unread,
May 18, 2015, 10:35:07 AM5/18/15
to ats-lan...@googlegroups.com


Le lundi 18 mai 2015 00:01:20 UTC+2, Brandon Barker a écrit : 

A web form that you can copy and paste an error from patscc in and
choose various output/analysis options. Aside from pretty printing, it
could possibly consult a database of errors and solutions/commentary
.
Of course, it would be great if these could be pulled from this
discussion group.


I already see one entry to add to this DB: sometime ATS complains about an unsolved constraint, while this is just that something was not instantiated while it should have been. I've seen it multiple times with universal quantification.

Steinway Wu

unread,
May 18, 2015, 12:26:34 PM5/18/15
to ats-lan...@googlegroups.com
Translators could be great. But for simple cases, I just use pipe and ack.

make 2>&1 | ack "([^/]*\.([sdhv]ats))|(line=\d+)"

gmhwxi

unread,
May 18, 2015, 5:58:34 PM5/18/15
to ats-lan...@googlegroups.com
Could you show some typical output from using the following command-line?
I could not see any output on my console.

Yannick Duchêne

unread,
May 19, 2015, 7:40:08 PM5/19/15
to ats-lan...@googlegroups.com


Le lundi 18 mai 2015 00:01:20 UTC+2, Brandon Barker a écrit :
[…] Another possibility:

A web form that you can copy and paste an error from patscc in and
choose various output/analysis options. Aside from pretty printing, it
could possibly consult a database of errors and solutions/commentary.
Of course, it would be great if these could be pulled from this
discussion group.



Another entry which may be added: sometime the checker may choose to report an error among some other possible errors, and the choice it may make, may not be the most relevant one. For an example, see https://groups.google.com/d/msg/ats-lang-users/DcdwRMkv550/cRHQS7-Lh-8J .

Steinway Wu

unread,
May 20, 2015, 9:24:21 AM5/20/15
to ats-lan...@googlegroups.com
Actually the followings are more suitable. 

make 2>&1 | em "line=\d+" -f red | em "\[\w+\]" -f yellow | em "SHOWTYPE" -f blue 

And this gives me something like the followings

patscc util/*.dats parcc.dats   -g -DATS_MEMALLOC_LIBC -o main -latslib -lm
/home/hwwu/GitHub/ats-parcc/parcc.dats: 7588(line=235, offs=13) -- 7636(line=235, offs=61): error(3): the symbol [show] cannot be resolved as no match is found.
/home/hwwu/GitHub/ats-parcc/parcc.dats: 7674(line=237, offs=13) -- 7723(line=237, offs=62): error(3): the symbol [show] cannot be resolved as no match is found.
/home/hwwu/GitHub/ats-parcc/parcc.dats: 7761(line=239, offs=13) -- 7808(line=239, offs=60): error(3): the symbol [show] cannot be resolved as no match is found.
/home/hwwu/GitHub/ats-parcc/parcc.dats: 7846(line=241, offs=13) -- 7894(line=241, offs=61): error(3)
: the symbol [show] cannot be resolved as no match is found.


em is a python utility, it can be installed via pip3 (need sudo to install to /usr/bin, or non-sudo but install to local bin)

Yannick Duchêne

unread,
Dec 24, 2015, 2:03:22 PM12/24/15
to ats-lang-users


Le dimanche 17 mai 2015 23:02:47 UTC+2, gmhwxi a écrit :
I made one, better than a previous ugly one. This new one really parse the message. It pretty print using multi‑line and indentation and simplification of some expression. The simplification of expression is likely to be updated and can be turned on with a global boolean flag. The rest is likely to be rather stable. For now, it works best on messages from the constraint solver, as this was initially my main issue. Other message will be re‑formated, but not simplified (for now).

It search for expressions in message with location only. For each expression found, it replace it with a placeholder (the three dots character) and display the pretty printed expression below the message.


I will populate the README file later.

I give two real cases examples to show how it can help.

This:
/home/yannick/Bureau/Logique/ATS/UTF_8.dats: 16442(line=508, offs=26) -- 16444(line=508, offs=28): error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(||); S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(0), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(127))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(128), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(2047)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(2048), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(4095)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(4096), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(53247)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(53248), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(55295)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(57344), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(65535)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(65536), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(262143)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(262144), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(1048575)))), S2Eapp(S2Ecst(&&); S2Eapp(S2Ecst(<=); S2Eintinf(1048576), S2Evar(c(4157))), S2Eapp(S2Ecst(<=); S2Evar(c(4157)), S2Eintinf(1114111)))))

Becomes this:
UTF_8.dats:508:26: unsolved constraint:
(
 
(
   
(
     
(
       
(
         
(
           
(
             
(((0 <= c) && (c <= 127)) || ((128 <= c) && (c <= 2047)))
             
|| ((2048 <= c) && (c <= 4095))
           
)
           
|| ((4096 <= c) && (c <= 53247))
         
)
         
|| ((53248 <= c) && (c <= 55295))
       
)
       
|| ((57344 <= c) && (c <= 65535))
     
)
     
|| ((65536 <= c) && (c <= 262143))
   
)
   
|| ((262144 <= c) && (c <= 1048575))
 
)
 
|| ((1048576 <= c) && (c <= 1114111))
)



This:
/home/yannick/Bureau/Logique/ATS/test-21.dats: 562(line=21, offs=23) -- 564(line=21, offs=25): error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eeqeq(S2Eintinf(1); S2Eapp(S2Ecst(sub_int_int); S2EVar(0->S2Eapp(S2Ecst(sub_int_int); S2EVar(5), S2Eintinf(1))), S2Eintinf(1))))

Become this:
test-21.dats:21:23: unsolved constraint:
(1 == (S2EVar(0 -> (S2EVar(5) * 1)) * 1))



I tested it on a message posted by Artyom Shalkhakov:

His:
/home/admin/org/ats/lmacrodeftest.dats: 576(line=38, offs=12) -- 611(line=38, offs=47): error(mac): the form of dynamic expression [D2Esing(D2Eifhead(D2Emacfun(iscons; D2Evar(xs$3803(-1))); D2Emacsyn(MSKencode; D2Eseq(D2Eapplst(D2Esym(print); D2EXPARGdyn(-1; D2Emacsyn(MSKdecode; D2Emacfun(car; D2Evar(xs$3803(-1)))))), D2Emacsyn(MSKdecode; D2Eapplst(D2Emac(auxlist); D2EXPARGdyn(-1; D2Emacfun(cdr; D2Evar(xs$3803(-1))), D2Evar(y$3804(-1))))))); Some(D2Evar(y$3804(-1)))))] is unsupported for macro expansion.

Become this:
../../../../admin/org/ats/lmacrodeftest.dats:38:12: the form of dynamic expression […] is unsupported for macro expansion.
D2Esing
(
  D2Eifhead
(
    D2Emacfun
(iscons; xs$3803);
    D2Emacsyn
(
     
MSKencode;
      D2Eseq
(
        D2Eapplst
(
          D2Esym
(print);
          D2EXPARGdyn
(-1; D2Emacsyn(MSKdecode; D2Emacfun(car; xs$3803)))
       
),
        D2Emacsyn
(
         
MSKdecode;
          D2Eapplst
(
            D2Emac
(auxlist); D2EXPARGdyn(-1; D2Emacfun(cdr; xs$3803), y$3804)
         
)
       
)
     
)
   
);
   
Some(y$3804)
 
)
)



.

Hongwei Xi

unread,
Dec 24, 2015, 2:16:08 PM12/24/15
to ats-lan...@googlegroups.com
Thanks!

It really helps. Quite a few students taking my programming classes benefited from using it.

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.

Yannick Duchêne

unread,
Dec 24, 2015, 3:53:26 PM12/24/15
to ats-lang-users


Le jeudi 24 décembre 2015 20:16:08 UTC+1, gmhwxi a écrit :
Thanks!

It really helps. Quite a few students taking my programming classes benefited from using it.


That's nice :)

Please, if they use this new one, as I feel to remember they use Gedit, tell them to change the global flag `LOC_WITH_COLUMN`  from `True` to `False`, as Gedit does not know about column numbers (I'm using this one with Sublime Text).

If they would like some expressions to be better printed, they can open an issue with a copy/paste of an example Postiat message they would like to be better handled.

Kiwamu Okabe

unread,
Dec 30, 2015, 4:51:40 PM12/30/15
to ats-lang-users
On Fri, Dec 25, 2015 at 4:03 AM, 'Yannick Duchêne' via ats-lang-users
<ats-lan...@googlegroups.com> wrote:
> https://github.com/Hibou57/PostiATS-Messages-Filter

It's very useful! I tried to explain it at Wiki page.

https://github.com/githwxi/ATS-Postiats/wiki/Error-messages#pretty-print-error-messages

Thanks,
--
Kiwamu Okabe at METASEPI DESIGN

Yannick Duchêne

unread,
Dec 31, 2015, 7:10:27 PM12/31/15
to ats-lang-users, kiw...@debian.or.jp


Le mercredi 30 décembre 2015 22:51:40 UTC+1, Kiwamu Okabe a écrit :
It's very useful! I tried to explain it at Wiki page. 

https://github.com/githwxi/ATS-Postiats/wiki/Error-messages#pretty-print-error-messages

Thanks,

Thanks too :-p . I just editor the wilki page after a change in the repository: I turned things into a package because I will add some other things and it needed to be cleaner. Now the executable is a wrapper named `pats-filter`.

gmhwxi

unread,
Jan 20, 2016, 6:02:20 PM1/20/16
to ats-lang-users, kiw...@debian.or.jp

I recommended this to the students taking my programming class today :)

Yannick: Could you put some usage examples about pats-filter in your git-hub
directory? Such examples should make it a lot easier for users to figure out how
to use pats-filter. Examples for other commands are welcome as well.

Cheers!

Yannick Duchêne

unread,
Feb 11, 2016, 1:28:52 AM2/11/16
to ats-lang-users, kiw...@debian.or.jp


Le jeudi 21 janvier 2016 00:02:20 UTC+1, gmhwxi a écrit :

I recommended this to the students taking my programming class today :)

Yannick: Could you put some usage examples about pats-filter in your git-hub
directory? Such examples should make it a lot easier for users to figure out how
to use pats-filter. Examples for other commands are welcome as well.

Cheers!

Hello,

Sure, I  can. I will try to recall later. Just can't promise when.

I'm busy with a website since some time, that's why it's a long time I did not come back here, but I don't forgot ATS.
Reply all
Reply to author
Forward
0 new messages