1
/* This file is part of Malaga, a system for Natural Language Analysis.
2
* Copyright (C) 1995-1999 Bjoern Beutel
5
* Universitaet Erlangen-Nuernberg
6
* Abteilung fuer Computerlinguistik
9
* e-mail: malaga@linguistik.uni-erlangen.de
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
25
/* description ==============================================================*/
27
/* This module parses Malaga values. */
29
/* includes =================================================================*/
45
#include "value_parser.h"
47
/* functions ================================================================*/
49
LOCAL void parse_symbol (void)
50
/* Parse a symbol and push it on the value stack. */
52
test_token (TOK_IDENT);
53
push_symbol_value (find_symbol (token_name));
57
/*---------------------------------------------------------------------------*/
59
LOCAL void parse_simple_value (void)
60
/* Parse a value and leave it on the value_stack. */
62
int_t n; /* number of values in list or record */
66
case '<': /* Parse a list. */
69
if (next_token != '>')
71
parse_simple_value ();
73
while (next_token == ',')
76
parse_simple_value ();
84
case '[': /* Parse a record. */
87
if (next_token != ']')
91
parse_simple_value ();
93
while (next_token == ',')
98
parse_simple_value ();
106
case TOK_IDENT: /* Parse a symbol. */
110
case TOK_STRING: /* Parse a string. */
112
encode_hangul (&token_string);
114
push_string_value (token_string, NULL);
118
case TOK_NUMBER: /* Parse a number value. */
119
push_number_value (token_number);
124
error ("value expected, not %s", token_as_text (next_token));
128
/*---------------------------------------------------------------------------*/
130
GLOBAL void parse_value_string (string_t value_string)
131
/* STACK EFFECTS: (nothing) -> <new_value>. *
132
* Parse <value_string> which must contain a value in text format.
133
* <new_value> is the content of <value_string>. */
135
set_scanner_input (value_string);
136
parse_simple_value ();
140
/* end of file ==============================================================*/