# "NOTES"

Notes pertaining to the parser.  

The parser specification (.yy) files and utility scripts (.awk)
have been tested succesfully with the following parser generators:

	yacc (traditional)
	bison-1.35
	bison-1.875
	bison-2.0

One version of bison known to produce d

The various parser generators emit differently formatted "human-readable"
grammar output with the -v option.  
Some scripts generate C-string tables and code based on this output, 
so the error messages reported may vary slightly.  

===============================================================================
Location tracking:

	Before bison-2.0 supported its own default location tracking
	structure, I already implemented one: struct token_position, 
	which is functionally identical.  
	The lexer uses this...

===============================================================================
Functions:

void yyerror(const char*);

	* Much magic going on here.  

	* Explain the global vs. local variable hackery: yacc vs. bison.

	* We actually bother to deallocate tokens on the parser symbol
	  stack before exit(1)-ing.  Just showing off the power of my hacks.  

	TODO (2005-05-01):
	rewrite {yacc,bison}-union-hack.awk to eliminate returning
	ART::parser::node* mother pointer type.
	All we really ever need with node* is de-allocation (delete), 
	what(ostream&) and where()... NOTHING ELSE.
	So just add new function tables in the style of yy_union_resolve.
	Get rid of the original, which returns the mother pointer type.  
	define: yyunion_what_where(ostream&);
	Consequence (benefit): eliminate node as mother base class of tokens!
	Token classes only need to meet the interface requirements.


===============================================================================
Interface:
	Something to consider trying:
	bison only (I think):
	%parse-param to add arguments to the prototype of int yyparse().
	flex only (I think):
	%lex-param to add arguments to the prototype of int yylex().

===============================================================================
Parser-generator-specific notes:

yacc:
	The parser action tables generated by yacc are not at all optimized, 
	i.e. multiple goto's have not been compressed.  
	As a result, the "possible rules" message reported by the 
	yyerror function may differ between yacc and bison, 
	which optimizes the parser state machine.  
	We went through to the trouble of supplying expected error
	messages in the test cases where this makes a difference.  

	The symbol stack is declared and defined as static global
	variables, arrays and tables.  
	One consequence of this is that yacc-generated parsers
	are not reentrant, it can never call itself (even indirectly).  

bison:
	Versions 1.35 and 1.875 ... not many issues.  

	A documented option for generating pure (reentrant) parsers 
	is the %pure-parser directive.  
	This will store yylval as only a local variable, making it
	globally inaccessible, which may be useless.  
	I haven't explored this option yet.  
	
bison-2.0:
	According to the manual, a new feature for invoking destructors
	(%destructor) is now available.  
	(Supposedly this feature became available in 1.875, but seldom used.)
	This is intended for deallocating memory on the symbol stack, 
	where the memory is being held in a pointer-member of the
	symbol's union type.  
	(Yes, unions of pointers are hideous no matter how you look at them.)
	Since we have a technique for freeing memory in the face of 
	single parse errors, we won't use this feature.  


