File: catsparse_lexerr.dats

package info (click to toggle)
ats2-lang 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,064 kB
  • sloc: ansic: 389,637; makefile: 7,123; lisp: 812; sh: 657; php: 573; python: 387; perl: 365
file content (109 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
(* ****** ****** *)
//
// CATS-parsemit
//
(* ****** ****** *)
//
// HX-2014-07-02: start
//
(* ****** ****** *)
//
#include
"share/atspre_define.hats"
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)

staload UN = $UNSAFE

(* ****** ****** *)

staload "./../SATS/catsparse.sats"

(* ****** ****** *)
//
implement
lexerr_make (loc, node) =
  '{ lexerr_loc= loc, lexerr_node= node }
//
(* ****** ****** *)
//
implement
the_lexerrlst_clear () =
  list_vt_free (the_lexerrlst_pop_all ())
//
(* ****** ****** *)

implement
print_lexerr (x) = fprint (stdout_ref, x)  
implement
prerr_lexerr (x) = fprint (stderr_ref, x)  
  
(* ****** ****** *)

implement
fprint_lexerr
  (out, x) = let
//
val () =
fprint! (out, x.lexerr_loc, ": ")
//
in
//
case+
x.lexerr_node of
| LEXERR_FEXPONENT_nil () =>
  {
    val () = fprintln! (out, "Floating number exponent is nil")
  }
| LEXERR_UNSUPPORTED_char (c) =>
  {
    val i = char2int0(c)
    val () = fprintln! (out, "Unrecognized char: ", c, "(", i, ")")
  }
//
end // end of [fprint_lexerr]

(* ****** ****** *)

implement
fprint_lexerrlst
  (out, xs) =
(
//
case+ xs of
| list_nil () => ()
| list_cons (x, xs) =>
  {
    val () = fprint_lexerr (out, x)
    val () = fprint_lexerrlst (out, xs)
  }
//
) (* end of [fprint_lexerrlst] *)

(* ****** ****** *)

implement
the_lexerrlst_print_free
  () = nerr where
{
//
  val xs =
    the_lexerrlst_pop_all ()
  // end of [val]
  val xs = list_vt_reverse (xs)
  val nerr = list_vt_length (xs)
  val () =
  if nerr > 0 then
  {
    val () = fprint (stderr_ref, "LexingErrors:\n")
    val () = fprint_lexerrlst (stderr_ref, $UN.list_vt2t(xs))
  } (* end of [if] *)
  val ((*freed*)) = list_vt_free (xs)
//
} (* end of [the_lexerrlst_print_free] *)

(* ****** ****** *)

(* end of [catsparse_lexerr.dats] *)