C compilation issue with an indexed, abstract, external type (templates not being instantiated)

Hello,

I’m trying out the following code (just modified the flat union example,
where said unions are put into a stack):

I think it should work, but it gives me C compilation errors, such as this
one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token

ATSINSmove_void(tmp23__1, PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977); ;
S2Eapp(S2Ecst(intfloat); S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?

I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn’t know the name of the algorithm until this moment :slight_smile:

I learned it from reading Frank Pfenning’s code about 20 years ago.On Thursday, April 28, 2016 at 3:42:10 AM UTC-4, Artyom Shalkhakov wrote:

On Thursday, April 28, 2016 at 10:51:21 AM UTC+6, gmhwxi wrote:

Try to move the following code to the top:

staload “libats/SATS/stkarray.sats”
staload _(anon) = “libats/DATS/stkarray.dats”

extern
fun{a:t@ype}
stkarray_peek_top
{m,n:int | n > 0}
(
stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n)
) :<!wrt> (a) //
endfun

implement{a}
stkarray_peek_top {m,n} (stk) = let
prval () = lemma_stkarray_param (stk)
val res = stkarray_takeout (stk)
val () = stkarray_insert
(stk, res)
in
res
end

val () = opt_some(…)

should change to

prval () = opt_some(…)

token_print is yet to be implemented.

Thank you for the suggestions, indeed this helped to fix the issue.

I’m off to debug the whole thing. Thanks!

On Thu, Apr 28, 2016 at 12:34 AM, Artyom Shalkhakov < artyo...@gmail.com> wrote:

On Thursday, April 28, 2016 at 10:02:41 AM UTC+6, gmhwxi wrote:

You just need to add the following line at the beginning:

staload “share/atspre_staload.hats”

Thank you very much, #including “share/atspre_stalod.hats” fixed it!

Now here’s a more contrived example:

shuntingyard.dats · GitHub

I’ve copied compilation errors verbatim (in the comment to that gist).

On Wed, Apr 27, 2016 at 11:46 PM, Artyom Shalkhakov < artyo...@gmail.com> wrote:

Hello,

I’m trying out the following code (just modified the flat union
example, where said unions are put into a stack):

stacked-union.dats · GitHub

I think it should work, but it gives me C compilation errors, such as
this one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token

ATSINSmove_void(tmp23__1,
PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977); ; S2Eapp(S2Ecst(intfloat);
S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?


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...@googlegroups.com.
To post to this group, send email to ats-l...@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/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com?utm_medium=email&utm_source=footer
.


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...@googlegroups.com.
To post to this group, send email to ats-l...@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/67d6d4e5-55c1-4ba5-b16e-4381611130a7%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/67d6d4e5-55c1-4ba5-b16e-4381611130a7%40googlegroups.com?utm_medium=email&utm_source=footer
.

You just need to add the following line at the beginning:

staload “share/atspre_staload.hats”

Thank you very much, #including “share/atspre_stalod.hats” fixed it!

Now here’s a more contrived example:

I’ve copied compilation errors verbatim (in the comment to that gist).On Wed, Apr 27, 2016 at 11:46 PM, Artyom Shalkhakov <artyo...@gmail.com <javascript:>> wrote:

Hello,

I’m trying out the following code (just modified the flat union example,
where said unions are put into a stack):

stacked-union.dats · GitHub

I think it should work, but it gives me C compilation errors, such as
this one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token

ATSINSmove_void(tmp23__1, PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977);
; S2Eapp(S2Ecst(intfloat); S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
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/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com?utm_medium=email&utm_source=footer
.

You just need to add the following line at the beginning:

staload "share/atspre_staload.hats"On Wed, Apr 27, 2016 at 11:46 PM, Artyom Shalkhakov < artyom.s...@gmail.com> wrote:

Hello,

I’m trying out the following code (just modified the flat union example,
where said unions are put into a stack):

stacked-union.dats · GitHub

I think it should work, but it gives me C compilation errors, such as this
one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token

ATSINSmove_void(tmp23__1, PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977); ;
S2Eapp(S2Ecst(intfloat); S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?


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/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com?utm_medium=email&utm_source=footer
.

I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn’t know the name of the algorithm until this moment :slight_smile:

Yes, actually, I was thinking about fixity resolution in ATS, and why it
works.

The classic approach to parsing with precedence, where one has to contort
the grammar, is really awful. If there are like 5 operators in the language
being parsed, it’s mostly okay, but it doesn’t really scale when there are
many operators to handle.

I learned it from reading Frank Pfenning’s code about 20 years ago.

I don’t think I understand why it works, so I decided to implement it
following the Wikipedia article.

I’ll make something neatly interactive with it.

Try to move the following code to the top:

staload “libats/SATS/stkarray.sats”
staload _(anon) = “libats/DATS/stkarray.dats”

extern
fun{a:t@ype}
stkarray_peek_top
{m,n:int | n > 0}
(
stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n)
) :<!wrt> (a) //
endfun

implement{a}
stkarray_peek_top {m,n} (stk) = let
prval () = lemma_stkarray_param (stk)
val res = stkarray_takeout (stk)
val () = stkarray_insert
(stk, res)
in
res
end

val () = opt_some(…)

should change to

prval () = opt_some(…)

token_print is yet to be implemented.

Thank you for the suggestions, indeed this helped to fix the issue.

I’m off to debug the whole thing. Thanks!

Try to move the following code to the top:

staload “libats/SATS/stkarray.sats”
staload _(anon) = “libats/DATS/stkarray.dats”

extern
fun{a:t@ype}
stkarray_peek_top
{m,n:int | n > 0}
(
stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n)
) :<!wrt> (a) //
endfun

implement{a}
stkarray_peek_top {m,n} (stk) = let
prval () = lemma_stkarray_param (stk)
val res = stkarray_takeout (stk)
val () = stkarray_insert
(stk, res)
in
res
end

val () = opt_some(…)

should change to

prval () = opt_some(…)

token_print is yet to be implemented.On Thu, Apr 28, 2016 at 12:34 AM, Artyom Shalkhakov < artyom.s...@gmail.com> wrote:

On Thursday, April 28, 2016 at 10:02:41 AM UTC+6, gmhwxi wrote:

You just need to add the following line at the beginning:

staload “share/atspre_staload.hats”

Thank you very much, #including “share/atspre_stalod.hats” fixed it!

Now here’s a more contrived example:

shuntingyard.dats · GitHub

I’ve copied compilation errors verbatim (in the comment to that gist).

On Wed, Apr 27, 2016 at 11:46 PM, Artyom Shalkhakov <artyo...@gmail.com wrote:

Hello,

I’m trying out the following code (just modified the flat union example,
where said unions are put into a stack):

stacked-union.dats · GitHub

I think it should work, but it gives me C compilation errors, such as
this one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token

ATSINSmove_void(tmp23__1, PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977);
; S2Eapp(S2Ecst(intfloat); S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?


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...@googlegroups.com.
To post to this group, send email to ats-l...@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/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com?utm_medium=email&utm_source=footer
.


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/67d6d4e5-55c1-4ba5-b16e-4381611130a7%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/67d6d4e5-55c1-4ba5-b16e-4381611130a7%40googlegroups.com?utm_medium=email&utm_source=footer
.

I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn’t know the name of the algorithm until this moment :slight_smile:

Yes, actually, I was thinking about fixity resolution in ATS, and why it
works.

The classic approach to parsing with precedence, where one has to contort
the grammar, is really awful. If there are like 5 operators in the language
being parsed, it’s mostly okay, but it doesn’t really scale when there are
many operators to handle.

It complicates the grammar and does not scale.

Whenever I teach this stuff, I always feel a bit guilty because I know it
is not a practical approach.