Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating: for handling non-ascii chars.

  • Loading branch information...
commit 8b1942e36707db958bb3beb607f3f3cd9bdce3d9 1 parent c1056d3
Hongwei Xi authored
View
6 libatsdoc/DATS/atsdoc_lexbuf.dats
@@ -75,6 +75,10 @@ staload "libatsdoc/SATS/atsdoc_lexbuf.sats"
//
(* ****** ****** *)
+macdef neof (i) = (,(i) != EOF)
+
+(* ****** ****** *)
+
viewtypedef
lexbuf_int_int
(m: int, n:int) =
@@ -226,7 +230,7 @@ in
end else let
val i = $R.reader_get_char (buf.reader)
in
- if i >= 0 then let
+ if neof(i) then let
val c = (i2uc)i
val m = $Q.queue_cap {uchar} (buf.cbuf)
in
View
6 libatsdoc/DATS/atsdoc_location.dats
@@ -44,6 +44,10 @@ staload "libatsdoc/SATS/atsdoc_location.sats"
(* ****** ****** *)
+macdef neof (i) = (,(i) != EOF)
+
+(* ****** ****** *)
+
assume
position_t0ype =
$extype_struct
@@ -98,7 +102,7 @@ position_copy (
implement
position_incby_char
(pos, i) =
-if i >= 0 then let
+if neof(i) then let
//
#define c2i int_of_char
//
View
12 libatsdoc/DATS/atsdoc_text.dats
@@ -76,6 +76,10 @@ staload "libatsdoc/SATS/atsdoc_text.sats"
(* ****** ****** *)
+macdef neof (i) = (,(i) != EOF)
+
+(* ****** ****** *)
+
local
staload
@@ -526,7 +530,7 @@ fun fprsub_ident {n:nat} (
) : void = let
val n = list_vt_length (cs)
in
- if n >= 0 then let
+ if n > 0 then let
val id = string_make_list_int ($UN.castvwtp1(cs), n)
val id = string_of_strbuf (id)
val sym = symbol_make_string (id)
@@ -553,7 +557,7 @@ fprsub_reader (out, inp) = let
fun aux (
out: FILEref, inp: &reader, cur: &int
) : void =
- if cur >= 0 then let
+ if neof(cur) then let
val fst = (i2c)cur
val () = cur := reader_get_char (inp)
in
@@ -568,7 +572,7 @@ fun aux (
and aux_SHARP (
out: FILEref, inp: &reader, cur: &int
) : void =
- if cur >= 0 then let
+ if neof(cur) then let
val cs = ident_get (inp, cur)
val dlrend = (cur = int_of('$')): bool
//
@@ -598,7 +602,7 @@ and aux_SHARP (
and aux_SLASH (
out: FILEref, inp: &reader, cur: &int
) : void =
- if cur >= 0 then let
+ if neof(cur) then let
val fst = (i2c)cur
val () = cur := reader_get_char (inp)
in
View
18 utils/atsdoc/atsdoc_translate.dats
@@ -78,8 +78,14 @@ staload "atsdoc_translate.sats"
(* ****** ****** *)
+macdef neof (i) = (,(i) != EOF)
+
+(* ****** ****** *)
+
fun funres_prfx () = "_tok"
+(* ****** ****** *)
+
local
val cntref = ref<int> (1)
@@ -168,7 +174,7 @@ ftesting_seq0
) : uint = let
val i = lexbuf_get_char (buf, nchr)
in
- if i >= 0 then
+ if neof(i) then
if f ((i2c)i)
then loop (buf, succ(nchr), f) else nchr
// end of [if]
@@ -192,7 +198,7 @@ testing_spaces
) : uint = let
val i = lexbufpos_get_char (buf, pos)
in
- if i >= 0 then (
+ if neof(i) then (
if SPACE_test ((i2c)i) then let
val () = posincbyc (pos, i) in loop (buf, pos, k+1u)
end else k // end of [if]
@@ -216,7 +222,7 @@ implement testing_literal
if string_isnot_at_end (lit, k) then let
val i = lexbuf_get_char (buf, nchr)
in
- if i >= 0 then
+ if neof(i) then
if ((i2c)i = lit[k])
then loop (buf, succ(nchr), lit, k+1) else ~1
// end of [if]
@@ -237,7 +243,7 @@ testing_ident
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then (
+if neof(i) then (
if IDENTFST_test ((i2c)i) then let
val () = posincby1 (pos)
val nchr = ftesting_seq0 (buf, pos, IDENTRST_test)
@@ -306,7 +312,7 @@ trans_top
//
in
//
-if i0 >= 0 then let
+if neof(i0) then let
val c = (i2c)i0 // the first character
val () = posincbyc (pos, i0)
in
@@ -391,7 +397,7 @@ trans_top_SLASH
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i in
case+ c of
| '\n' => let
View
22 utils/atsdoc/atsdoc_translate_item.dats
@@ -65,6 +65,10 @@ staload "atsdoc_translate.sats"
(* ****** ****** *)
+macdef neof (i) = (,(i) != EOF)
+
+(* ****** ****** *)
+
implement
fprint_funarg (out, x) =
case+ x of
@@ -210,7 +214,7 @@ trans_extcode_START
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i
in
case+ c of
@@ -267,7 +271,7 @@ trans_string
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i
(*
val () = fprintf (stderr_ref, "trans_dstring: c = %c\n", @(c))
@@ -338,7 +342,7 @@ trans_string_SLASH
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i in
case+ c of
| _ when c = SDQ => let
@@ -386,7 +390,7 @@ trans_funres (buf, pos) = let
val i = lexbufpos_get_char (buf, pos)
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i in
case+ c of
| '\[' => let
@@ -406,7 +410,9 @@ trans_funres_LBRACKET
(buf, pos0, pos) = let
//
val k = testing_ident (buf, pos)
- val () = if k < 0 then lexbufpos2_docerr (buf, pos0, pos, DE_FUNRES_none)
+ val () = if k < 0 then
+ lexbufpos2_docerr (buf, pos0, pos, DE_FUNRES_none)
+ // end of [val]
val k = (if k >= 0 then k else 0): int
val k = (uint_of)k
//
@@ -457,7 +463,7 @@ trans_funarg (buf, pos) = let
//
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i in
case+ c of
| SQUOTE => let
@@ -558,7 +564,7 @@ trans_funarglst
//
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i
(*
val () = fprintf (stderr_ref, "trans_funarglst: c = %c\n", @(c))
@@ -593,7 +599,7 @@ trans_funarglst_OPEN
//
in
//
-if i >= 0 then let
+if neof(i) then let
val c = (i2c)i in
case+ c of
| _ when c = cls => let
Please sign in to comment.
Something went wrong with that request. Please try again.