Patscc-pp

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.

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.

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)
)
)

.

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

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.

[…] 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 .

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.

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

Error messages · githwxi/ATS-Postiats Wiki · GitHub

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.

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

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!On Thursday, December 31, 2015 at 7:10:27 PM UTC-5, Yannick Duchêne wrote:

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.

Error messages · githwxi/ATS-Postiats Wiki · GitHub

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.

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)
See: em.readthedocs.orgOn Monday, May 18, 2015 at 5:58:34 PM UTC-4, gmhwxi wrote:

Could you show some typical output from using the following command-line?
I could not see any output on my console.

On Monday, May 18, 2015 at 12:26:34 PM UTC-4, Steinway Wu wrote:

Translators could be great. But for simple cases, I just use pipe and ack.

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

On Sunday, May 17, 2015 at 5:02:47 PM UTC-4, gmhwxi wrote:

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.

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.

Thanks!

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

That’s nice :slight_smile:

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.

Thanks!

It really helps. Quite a few students taking my programming classes
benefited from using it.On Thu, Dec 24, 2015 at 2:03 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le dimanche 17 mai 2015 23:02:47 UTC+2, gmhwxi a écrit :

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.

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.

GitHub - Hibou57/PostiATS-Utilities: Messages pretty printer, JSONized files cache and documentation utilities, for ATS/PostiATS (ATS2)

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)
)
)

.


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 https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/4b264fc6-2e32-4a1a-af49-58d763586a78%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/4b264fc6-2e32-4a1a-af49-58d763586a78%40googlegroups.com?utm_medium=email&utm_source=footer
.

Could you show some typical output from using the following command-line?
I could not see any output on my console.On Monday, May 18, 2015 at 12:26:34 PM UTC-4, Steinway Wu wrote:

Translators could be great. But for simple cases, I just use pipe and ack.

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

On Sunday, May 17, 2015 at 5:02:47 PM UTC-4, gmhwxi wrote:

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.

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.

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?

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.On Sun, May 17, 2015 at 5:32 PM, ‘Yannick Duchêne’ via ats-lang-users ats-lan...@googlegroups.com wrote:

Le dimanche 17 mai 2015 23:02:47 UTC+2, gmhwxi a écrit :

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.

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?


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

Translators could be great. But for simple cases, I just use pipe and ack.

make 2>&1 | ack "([^/]*.([sdhv]ats))|(line=\d+)"On Sunday, May 17, 2015 at 5:02:47 PM UTC-4, gmhwxi wrote:

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.