NAME ^

input.pir - Setting up input and reading input

DESCRIPTION ^

Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved. CVS Info: $Id$ History: Ported from GNU m4 1.4 References: http://www.gnu.org/software/m4/m4.html

SUBROUTINES ^

void input_init( Hash state ) ^

Initialise some stacks and some regexes

'token_stack' 'input_stack' contains files, strings and macro definitions 'wrapup_stack' 'word_rulesub' recognizes TOKEN_WORD. 'string_rulesub' recognizes TOKEN_STRING 'simple_rulesub' recognizes TOKEN_SIMPLE 'comment_rulesub' recognizes comments, returned as TOKEN_SIMPLE

TODO: recognize nested quoted strings

void push_file( Hash state, string filename ) ^

Stores a filename on a stack TODO: open these files and complain when they don't or pass filehandles

string next_token( Hash state ) ^

Parse and return a single token from the input stream. A token can either be TOKEN_EOF, if the input_stack is empty; it can be TOKEN_STRING for a quoted string; TOKEN_WORD for something that is a potential macro name; and TOKEN_SIMPLE for any single character that is not a part of any of the previous types. | Next_token () return the token type and the token data.

Uses regular expressions for finding tokens.


parrot