-
+ 30ACFFBB85D590F74E7E9B76F5611663BDA26AF35E38316F633A752A9248AC9B7E61E72BD411252A4BE85B2F89E442F53F5E68A0414CFBBD6376B30F99F3B1BEadalisp/src/parser.ads(0 . 0)(1 . 56)
2318 -- S-expression parser. According to the current spec, any of the
2319 -- following objects constitute a S-expr:
2320 --
2321 -- - atom: a sequence containing any characters except spaces or parens,
2322 -- i.e. ( or ); atoms are separated by these characters and may not
2323 -- begin with any of (, ), #, . or '; if an atom is composed only of
2324 -- numeric decimal characters, then it is parsed as a number; otherwise
2325 -- it is parsed as an interned symbol.
2326 --
2327 -- - hash expression: any expression beginning with #; currently,
2328 -- expression beginning with # are the boolean values #t and #f, and
2329 -- escaped characters, e.g. #\a (the character corresponding to the
2330 -- letter a).
2331 --
2332 -- - cons expression: cons expressions begin with a (, contain any
2333 -- number of space-separated sub-expressions and end with ), e.g. (a b
2334 -- c d) denotes the list containing the symbols a, b, c and d, ()
2335 -- denotes the empty list, etc.; a cons expression may optionally
2336 -- contain a period (.) token before the last element, signifying that
2337 -- the last element is set as the cdr of the last cons cell, e.g. (1 2
2338 -- . 3) corresponds to (cons 1 (cons 2 3)).
2339 --
2340 -- - quoted expression: any expression beginning with a single quote (')
2341 -- token; 'expr (where expr is an arbitrary S-expression) gets
2342 -- translated to (quote expr).
2343 with LispM; use LispM;
2344
2345 package Parser is
2346 type TokenID is (Error_Token, Bool_Token, Num_Token, List_Token,
2347 Char_Token, Symbol_Token, ListE_Token, ListP_Token,
2348 Quoted_Token);
2349
2350 -- Given a string, check if all its characters are digits.
2351 procedure Parse_Integer(Str : in MemPtr;
2352 Success : out Boolean;
2353 I : out Long_Integer);
2354 -- Eat whitespace.
2355 procedure Eat_Whitespace;
2356
2357 -- Parse a list of characters not in the reserved set.
2358 procedure Parse_Atom(P : out MemPtr);
2359
2360 -- Parse a hash-prepended expression.
2361 procedure Parse_Hash(P : out MemPtr; TID : out TokenID);
2362
2363 -- Parse cons objects, i.e. lists and pairs.
2364 procedure Parse_Cons(P : out MemPtr);
2365
2366 -- Parse quoted expression.
2367 procedure Parse_Quoted(P : out MemPtr; TID : out TokenID);
2368
2369 -- Parse an S-expression given as input on the console. Output a
2370 -- pointer to the parsed expression and its type, as represented by
2371 -- TokenID.
2372 procedure Parse(P : out MemPtr; TID : out TokenID);
2373 end Parser;