Where is "FILE" view type on ATS2?

46 views
Skip to first unread message

Kiwamu Okabe

unread,
May 9, 2015, 4:29:02 AM5/9/15
to ats-lang-users, ats-lang-users
Hi all,

I start to port atsdoc into ATS2.
However, following error occurs.

```
$ make |& head -2
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c atsdoc_main.dats
/home/kiwamu/src/ATS-Postiats.masterq/libatsdoc/SATS/libatsdoc_lexbuf.sats:
1979(line=60, offs=10) -- 1983(line=60, offs=14): error(2):
unrecognized static identifier [FILE].
```

It's caused by following code.

```
fun lexbuf_initialize_filp
{m:file_mode} {l:addr} (
pfmod: file_mode_lte (m, r)
, pffil: FILE m @ l
| r: &lexbuf? >> lexbuf, p: ptr l
) : void // end of [lexbuf_initialize_filp]
```

Where is "FILE" view type on ATS2?

Thank's,
--
Kiwamu Okabe at METASEPI DESIGN

Hongwei Xi

unread,
May 9, 2015, 7:51:56 AM5/9/15
to ats-lan...@googlegroups.com
It is in ${PATSHOME}/libc/SATS/stdio.sats; it is called FILE_v.

--
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/CAEvX6dmx%3Dz7uRBLhDr8TfZit2VRkCua_JTKt6jozfwBMN-7njg%40mail.gmail.com.

Kiwamu Okabe

unread,
May 13, 2015, 2:36:07 AM5/13/15
to ats-lang-users
Hi Hongwei,

On Sat, May 9, 2015 at 8:51 PM, Hongwei Xi <gmh...@gmail.com> wrote:
> It is in ${PATSHOME}/libc/SATS/stdio.sats; it is called FILE_v.

Thank's. I got some progress.

https://github.com/master-q/ATS-Postiats/tree/feature/atsdoc

But I have found the other error. How to fix it?

The error is following:

```
$ make |& head -2
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c atsdoc_main.dats
/home/kiwamu/src/ATS-Postiats.masterq/utils/atsdoc/atsdoc_main.dats:
3191(line=103, offs=29) -- 3203(line=103, offs=41): error(3): the
dynamic expression is expected to be a pointer.
```

And code is following:

```
implement
comarglst_parse
{n} (argc, argv) = let
viewtypedef arglst (n: int) = list_vt (comarg, n)
fun loop {i:nat | i <= n} {l:addr} .<n-i>.
(pf0: arglst 0 @ l | argv: &(@[string][n]), i: int i, p: ptr l)
:<cloref> (arglst (n-i) @ l | void) =
if i < argc then let
val+ ~list_vt_nil () = !p
val arg = comarg_parse (argv.[i])
val lst0 = list_vt_cons (arg, list_vt_nil ())
val+ list_vt_cons (_, lst) = lst0
val (pf | ()) = loop (view@ (!lst) | argv, i+1, lst) // <= Here!
in
fold@ lst0; !p := lst0; (pf0 | ())
end else (pf0 | ())
val lst0 = list_vt_nil {comarg} ()
val (pf | ()) = loop (view@ lst0 | argv, 0, lst0) // tail-call
prval () = view@ lst0 := pf
in
lst0
end // end of [comarglst_parse]
```

Hongwei Xi

unread,
May 13, 2015, 3:33:43 AM5/13/15
to ats-lan...@googlegroups.com
>>val (pf | ()) = loop (view@ (!lst) | argv, i+1, lst) // <= Here!

should be written as follows in ATS2:

val (pf | ()) = loop (view@lst | argv, i+1, addr@lst)

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

gmhwxi

unread,
May 13, 2015, 4:07:51 AM5/13/15
to ats-lan...@googlegroups.com, kiw...@debian.or.jp
I would implement the function in ATS2 as follows:

implement
comarglst_parse
 
{n} (argc, argv) = let
//
val p
= $UN.cast{ptr}(argv)
//
implement
tabulate$fopr
<comarg> (i) =
  comarg_parse
($UN.ptr0_get_at<string> (p, i))
//
in
  list_tabulate
<comarg> (argc)

end // end of [comarglst_parse]

Kiwamu Okabe

unread,
May 13, 2015, 6:56:07 AM5/13/15
to ats-lang-users
Hi Hongwei,
Sorry for my frequent mail.
I should progress inch by inch.

On Wed, May 13, 2015 at 5:07 PM, gmhwxi <gmh...@gmail.com> wrote:
> implement
> comarglst_parse
> {n} (argc, argv) = let
> //
> val p = $UN.cast{ptr}(argv)
> //
> implement
> tabulate$fopr<comarg> (i) =
> comarg_parse($UN.ptr0_get_at<string> (p, i))
> //
> in
> list_tabulate<comarg> (argc)
> end // end of [comarglst_parse]

I think your code is applied with some patch.
Next problem is fopen. Following error occurs while fopen fucntion should
return view and dynamic value.

```
$ make |& head -2
/home/kiwamu/src/ATS-Postiats.masterq/bin/patscc -g -O2 -c atsdoc_main.dats
/home/kiwamu/src/ATS-Postiats.masterq/utils/atsdoc/atsdoc_main.dats:
5274(line=218, offs=7) -- 5288(line=218, offs=21): error(3): the
tuple/record pattern is ill-typed.
```

The code is following:

```
fun outcode_set_filename
(path: string): void = let
val (pfopt | filp) = fopen (path, file_mode_w) // <= Here!
in
//
if filp > the_null_ptr then let
prval Some_v (pffil) = pfopt
val filp = __cast (pffil | filp) where {
extern castfn __cast {m:fm} {l:addr} (pf: FILE_v (l, m) | p: ptr l): FILEref
} // end of [val]
in
outcode_set (OUTCHANptr (filp))
end else let
prval None_v () = pfopt in outcode_set (OUTCHANref (stderr_ref))
end // end of [if]
//
end // end of [outcode_set_filename]
Message has been deleted

gmhwxi

unread,
May 13, 2015, 9:57:17 AM5/13/15
to ats-lan...@googlegroups.com, kiw...@debian.or.jp
>>Sorry for my frequent mail.

Not all. Thanks for doing it.

Maybe we could re-write ATS2 in ATS2 someday :)

The problem you encountered is due to fopen being given
different types in ATS1 and ATS2. Here is my suggestion:

Create a file, say, atsdoc_mylib.dats, and then put into it
various library functions you need and their ATS1 types. Instead of
using ATS2 library, you try to use atsdoc_mylib.dats. I will be happy
to set up this for you if you like. Of course, it is always more fun if
you try it on your own :)
Reply all
Reply to author
Forward
0 new messages