1 /* Scheme/Guile language support routines for GDB, the GNU debugger.
2 Copyright 1995, 1996, 2000 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
24 #include "expression.h"
25 #include "parser-defs.h"
32 #define USE_EXPRSTRING 0
34 static void scm_lreadparen (int);
35 static int scm_skip_ws (void);
36 static void scm_read_token (int, int);
37 static LONGEST
scm_istring2number (char *, int, int);
38 static LONGEST
scm_istr2int (char *, int, int);
39 static void scm_lreadr (int);
42 scm_istr2int (char *str
, int len
, int radix
)
50 return SCM_BOOL_F
; /* zero scm_length */
57 return SCM_BOOL_F
; /* bad if lone `+' or `-' */
92 return SCM_BOOL_F
; /* bad digit for radix */
97 return SCM_BOOL_F
; /* not a digit */
103 return SCM_MAKINUM (inum
);
107 scm_istring2number (char *str
, int len
, int radix
)
111 char ex_p
= 0, rx_p
= 0; /* Only allow 1 exactness and 1 radix prefix */
116 if (*str
== '+' || *str
== '-') /* Catches lone `+' and `-' for speed */
119 while ((len
- i
) >= 2 && str
[i
] == '#' && ++i
)
165 return scm_istr2int (&str
[i
], len
- i
, radix
);
167 return scm_istr2int (&str
[i
], len
- i
, radix
);
173 return scm_istr2flo (&str
[i
], len
- i
, radix
);
181 scm_read_token (int c
, int weird
)
201 case '\0': /* End of line */
242 switch ((c
= *lexptr
++))
249 switch ((c
= *lexptr
++))
270 scm_lreadparen (int skipping
)
274 int c
= scm_skip_ws ();
275 if (')' == c
|| ']' == c
)
279 error ("missing close paren");
280 scm_lreadr (skipping
);
285 scm_lreadr (int skipping
)
299 scm_lreadparen (skipping
);
303 error ("unexpected #\\%c", c
);
307 str
.ptr
= lexptr
- 1;
308 scm_lreadr (skipping
);
311 struct value
*val
= scm_evaluate_string (str
.ptr
, lexptr
- str
.ptr
);
312 if (!is_scmvalue_type (VALUE_TYPE (val
)))
313 error ("quoted scm form yields non-SCM value");
314 svalue
= extract_signed_integer (VALUE_CONTENTS (val
),
315 TYPE_LENGTH (VALUE_TYPE (val
)));
316 goto handle_immediate
;
323 scm_lreadr (skipping
);
331 scm_lreadparen (skipping
);
336 goto handle_immediate
;
340 goto handle_immediate
;
356 case '*': /* bitvector */
357 scm_read_token (c
, 0);
360 scm_read_token (c
, 1);
362 case '\\': /* character */
364 scm_read_token (c
, 0);
367 j
= 1; /* here j is the comment nesting depth */
374 error ("unbalanced comment");
378 if ('#' != (c
= *lexptr
++))
384 if ('|' != (c
= *lexptr
++))
395 scm_lreadr (skipping
);
399 while ('\"' != (c
= *lexptr
++))
402 switch (c
= *lexptr
++)
405 error ("non-terminated string literal");
434 str
.ptr
= lexptr
- 1;
435 scm_read_token (c
, 0);
438 svalue
= scm_istring2number (str
.ptr
, lexptr
- str
.ptr
, 10);
439 if (svalue
!= SCM_BOOL_F
)
440 goto handle_immediate
;
446 scm_read_token ('-', 0);
452 str
.ptr
= lexptr
- 1;
453 scm_read_token (c
, 0);
457 str
.length
= lexptr
- str
.ptr
;
458 if (str
.ptr
[0] == '$')
460 write_dollar_variable (str
);
463 write_exp_elt_opcode (OP_NAME
);
464 write_exp_string (str
);
465 write_exp_elt_opcode (OP_NAME
);
472 write_exp_elt_opcode (OP_LONG
);
473 write_exp_elt_type (builtin_type_scm
);
474 write_exp_elt_longcst (svalue
);
475 write_exp_elt_opcode (OP_LONG
);
483 while (*lexptr
== ' ')
486 scm_lreadr (USE_EXPRSTRING
);
488 str
.length
= lexptr
- start
;
490 write_exp_elt_opcode (OP_EXPRSTRING
);
491 write_exp_string (str
);
492 write_exp_elt_opcode (OP_EXPRSTRING
);
This page took 0.038744 seconds and 4 git commands to generate.