NAME ^

input.pir - Setting up input and reading input

DESCRIPTION ^

Copyright: 2004-2005 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 put them into the Hash state['stack']:

state['stack';'token'] not used yet

state['stack';'input'] contains files, strings and macro definitions

state['stack';'wrapup'] not used yet

Initialize some PGE rulesubs and put them into the Hash state['rulesub']:

state['rulesub';'word'] recognizes TOKEN_WORD.

state['rulesub';'string'] recognizes TOKEN_STRING

state['rulesub';'simple'] recognizes TOKEN_SIMPLE

state['rulesub';'simple'] recognizes comments, returned as TOKEN_SIMPLE

TOOO: 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 state['stack';'input'] 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