1 /* Scheme/Guile language support routines for GDB, the GNU debugger.
3 Copyright 1995, 1996, 2000, 2003 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include "expression.h"
26 #include "parser-defs.h"
33 #define USE_EXPRSTRING 0
35 static void scm_lreadparen (int);
36 static int scm_skip_ws (void);
37 static void scm_read_token (int, int);
38 static LONGEST
scm_istring2number (char *, int, int);
39 static LONGEST
scm_istr2int (char *, int, int);
40 static void scm_lreadr (int);
43 scm_istr2int (char *str
, int len
, int radix
)
51 return SCM_BOOL_F
; /* zero scm_length */
58 return SCM_BOOL_F
; /* bad if lone `+' or `-' */
93 return SCM_BOOL_F
; /* bad digit for radix */
98 return SCM_BOOL_F
; /* not a digit */
104 return SCM_MAKINUM (inum
);
108 scm_istring2number (char *str
, int len
, int radix
)
112 char ex_p
= 0, rx_p
= 0; /* Only allow 1 exactness and 1 radix prefix */
117 if (*str
== '+' || *str
== '-') /* Catches lone `+' and `-' for speed */
120 while ((len
- i
) >= 2 && str
[i
] == '#' && ++i
)
166 return scm_istr2int (&str
[i
], len
- i
, radix
);
168 return scm_istr2int (&str
[i
], len
- i
, radix
);
174 return scm_istr2flo (&str
[i
], len
- i
, radix
);
182 scm_read_token (int c
, int weird
)
202 case '\0': /* End of line */
243 switch ((c
= *lexptr
++))
250 switch ((c
= *lexptr
++))
271 scm_lreadparen (int skipping
)
275 int c
= scm_skip_ws ();
276 if (')' == c
|| ']' == c
)
280 error ("missing close paren");
281 scm_lreadr (skipping
);
286 scm_lreadr (int skipping
)
300 scm_lreadparen (skipping
);
304 error ("unexpected #\\%c", c
);
308 str
.ptr
= lexptr
- 1;
309 scm_lreadr (skipping
);
312 struct value
*val
= scm_evaluate_string (str
.ptr
, lexptr
- str
.ptr
);
313 if (!is_scmvalue_type (value_type (val
)))
314 error ("quoted scm form yields non-SCM value");
315 svalue
= extract_signed_integer (VALUE_CONTENTS (val
),
316 TYPE_LENGTH (value_type (val
)));
317 goto handle_immediate
;
324 scm_lreadr (skipping
);
332 scm_lreadparen (skipping
);
337 goto handle_immediate
;
341 goto handle_immediate
;
357 case '*': /* bitvector */
358 scm_read_token (c
, 0);
361 scm_read_token (c
, 1);
363 case '\\': /* character */
365 scm_read_token (c
, 0);
368 j
= 1; /* here j is the comment nesting depth */
375 error ("unbalanced comment");
379 if ('#' != (c
= *lexptr
++))
385 if ('|' != (c
= *lexptr
++))
396 scm_lreadr (skipping
);
400 while ('\"' != (c
= *lexptr
++))
403 switch (c
= *lexptr
++)
406 error ("non-terminated string literal");
435 str
.ptr
= lexptr
- 1;
436 scm_read_token (c
, 0);
439 svalue
= scm_istring2number (str
.ptr
, lexptr
- str
.ptr
, 10);
440 if (svalue
!= SCM_BOOL_F
)
441 goto handle_immediate
;
447 scm_read_token ('-', 0);
453 str
.ptr
= lexptr
- 1;
454 scm_read_token (c
, 0);
458 str
.length
= lexptr
- str
.ptr
;
459 if (str
.ptr
[0] == '$')
461 write_dollar_variable (str
);
464 write_exp_elt_opcode (OP_NAME
);
465 write_exp_string (str
);
466 write_exp_elt_opcode (OP_NAME
);
473 write_exp_elt_opcode (OP_LONG
);
474 write_exp_elt_type (builtin_type_scm
);
475 write_exp_elt_longcst (svalue
);
476 write_exp_elt_opcode (OP_LONG
);
484 while (*lexptr
== ' ')
487 scm_lreadr (USE_EXPRSTRING
);
489 str
.length
= lexptr
- start
;
491 write_exp_elt_opcode (OP_EXPRSTRING
);
492 write_exp_string (str
);
493 write_exp_elt_opcode (OP_EXPRSTRING
);
This page took 0.038174 seconds and 4 git commands to generate.