parse_string (string, use_gamma?=nil, parse_all?=nil)
A character string representing either a Lisp expression or a Gamma statement.
An optional argument that defaults to nil. If nil, the Lisp parser will be used, otherwise the Gamma parser will be used.
An optional argument that defaults to nil. If nil, only the first statement in the string will be parsed, otherwise all statements up to the end of the string will be paresed..
If parse_all is nil, return the first statement in the string in internal form. If parse_all is non-nil, return all statements in the string as a list of expressions in internal form. If an error occurs during parsing, this function will throw an error.
This function parses the input string using either the Lisp parser or the Gamma parser, and returns either the first complete statement found in the string or all of the statements to the end of the string.
If only the first statement is parsed, the rest of the string is ignored, even if it is invalid. The result is returned in internal form, effectively an executable Lisp representation. Internal form can be passed directly to the eval function for evaluation.
If all statements are returned, they are returned in a list, even if there is only one statement in the string. The resulting list can be passed directly to eval_list.
Gamma> a = parse_string("hello"); hello Gamma> b = parse_string("(cos 5)"); (cos 5) Gamma> c = parse_string("(+ 5 6) (/ 6 3)"); (+ 5 6) Gamma> eval(b); 0.28366218546322624627 Gamma> eval(c); 11 Gamma>
Using optional arguments:
Gamma> parse_string("cos(5);", t); (cos 5) Gamma> parse_string("cos(5); sin(5);", t); (cos 5) Gamma> parse_string("cos(5); sin(5);", t, t); ((cos 5) (sin 5)) Gamma> parse_string ("if (x < 1) y = 1; else y = 0;", t) (if (< x 1) (setq y 1) (setq y 0) ) Gamma>
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.