%{
/* Parser 
	Id: $Id: vbp.y,v 1.2 2004/04/13 04:48:36 tommieb Exp tommieb $
	Revision: $Revision: 1.2 $
	Date: $Date: 2004/04/13 04:48:36 $
	Author: $Author: tommieb $

    This program is free software; you can redistribute it and/or modify
    it under the terms of version 2 of the GNU General Public License as 
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    Send me an email if you find this useful. 
    Tom P. Brennan. 2004.

*/
#include 
extern char yytext[];
extern int vbp_tokenpos, vbp_lineno, vbp_errorflag;
%}

%union
{
	char *string;
	int integer;
	float numeral;
}

%token  OP_EQUAL OP_SEMICOLON OP_HASH OP_COLON OP_LSQBRACKET OP_RSQBRACKET
%token  FORM CLASS MODULE STARTUP NAME ICONFORM EXENAME32 OBJECT REFERENCE
%token  /*OP_LBRACKET OP_RBRACKET*/ FAVORPENTIUMPRO TRADEMARK

%token  LITERAL_STRING IDENTIFIER LITERAL_GUID LITERAL_REFERENCE
%token  NUMERIC_CONSTANT
%type  simple_name

%start project

%%
/*
**--------------------------------------- (Start State) Project! ---------------------------------------
*/
project:
	project_statements
	;
	
project_statements:
	| project_statements project_statement
	;
	
project_statement:
	attribute_stmt
	| section_stmt
	;

attribute_stmt:
	FORM OP_EQUAL simple_name			
	| CLASS OP_EQUAL class_filename
	| MODULE OP_EQUAL module_filename
	| STARTUP OP_EQUAL LITERAL_STRING	
	| NAME OP_EQUAL LITERAL_STRING		
	| ICONFORM OP_EQUAL LITERAL_STRING	
	| EXENAME32 OP_EQUAL LITERAL_STRING	
	| REFERENCE OP_EQUAL LITERAL_REFERENCE OP_HASH NUMERIC_CONSTANT OP_HASH NUMERIC_CONSTANT OP_HASH simple_name OP_HASH simple_name
	| OBJECT OP_EQUAL LITERAL_GUID OP_HASH NUMERIC_CONSTANT OP_HASH NUMERIC_CONSTANT OP_COLON simple_name
	| FAVORPENTIUMPRO TRADEMARK OP_EQUAL constant_value
	| simple_name OP_EQUAL constant_value
	;

class_filename:
	simple_name OP_COLON simple_name	
	;

module_filename:
	simple_name OP_COLON simple_name	
	;
	
simple_name:
	IDENTIFIER	{ $$ = $1; }
	;

constant_value:
	LITERAL_STRING
	| NUMERIC_CONSTANT
	| IDENTIFIER
	;
	
section_stmt:
	OP_LSQBRACKET simple_name OP_RSQBRACKET
	;
%%
/*#ifdef TEST_LB_LEX
main()
{
	yydebug=0;
	vbpparse();
}
#endif*/
vbperror(char *msg)
{
	fprintf(stderr, "Bison (VBP) error at line: (%d). %s\n", vbp_lineno, msg);
	vbp_errorflag = 1;
}
/*
** 1. bison -d -t -v --report=all -y -pvbp vbp.y
** 2. mv y.tab.c vbp_parse.c
** 3. mv y.tab.h vbp.tab.h
** 4. flex -dlitI -Pvbp vbp.l > vbp_lex.c
** 5. gcc -DTEST_LB_LEX -c vbp_parse.c
** 6. gcc -c vbp_lex.c
** 7. gcc -c vbp_parser vbp_parse.o vbp_lex.o
*/

    Source: geocities.com/wabbitty2002