%{
/* Lexer/Scanner 
	Id: $Id: vbp.l,v 1.1 2004/04/11 19:00:17 tommieb Exp tommieb $
	Revision: $Revision: 1.1 $
	Date: $Date: 2004/04/11 19:00:17 $
	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 
#include 
#include "vbp.tab.h"
	/* #define return(x)	printf("%s\n", x) */
%}

whitespace		[\t ]+
literal_string	\"[^\"\n]*[\"]
eol				(_|\n|\r|\f|\012|\015)?
num				[-+]?[0-9]+
ident_char		[_a-zA-Z.][a-zA-Z0-9 ._\\]*
double_literal	-?(([0-9]+)|([0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?)
guid_literal	(['{']+[A-Za-z0-9-]*['}']+)
%{
int vbp_lineno = 1, vbp_tokenpos = 0;
%}

%array yytext
%%
{whitespace}			{	vbp_tokenpos++; }
{eol}					{	vbp_tokenpos = 0;
							vbp_lineno++;
						}
"="						{	vbp_tokenpos += yyleng; return (OP_EQUAL); }
":"						{	vbp_tokenpos += yyleng; return (OP_SEMICOLON); }
"["						{	vbp_tokenpos += yyleng; return (OP_LSQBRACKET); }
"]"						{	vbp_tokenpos += yyleng; return (OP_RSQBRACKET); }
"#"						{	vbp_tokenpos += yyleng; return (OP_HASH); }
";"						{	vbp_tokenpos += yyleng; return (OP_COLON); }
	/*"("						{	tokenpos += yyleng; return (OP_LBRACKET); }
")"						{	tokenpos += yyleng; return (OP_RBRACKET); }*/
"Form"					{	vbp_tokenpos += yyleng; return (FORM); }
"Class"					{	vbp_tokenpos += yyleng; return (CLASS); }
"Module"				{	vbp_tokenpos += yyleng; return (MODULE); }
"Startup"				{	vbp_tokenpos += yyleng; return (STARTUP); }
"Name"					{	vbp_tokenpos += yyleng; return (NAME); }
"IconForm"				{	vbp_tokenpos += yyleng; return (ICONFORM); }
"ExeName32"				{	vbp_tokenpos += yyleng; return (EXENAME32); }
"Object"				{	vbp_tokenpos += yyleng; return (OBJECT); }
"Reference"				{	vbp_tokenpos += yyleng; return (REFERENCE); }
"FavorPentiumPro"		{	vbp_tokenpos += yyleng; return (FAVORPENTIUMPRO); }
"(tm)"					{	vbp_tokenpos += yyleng; return (TRADEMARK); }
{double_literal} {
				vbp_tokenpos += yyleng;
				vbplval.numeral = atof(yytext);
				return NUMERIC_CONSTANT; 
				/* printf("A Numeric Constant!\n"); */
			}
{ident_char}		{	
						vbplval.string = (char *) strdup(yytext);
						vbp_tokenpos += yyleng;
						/* printf("An identifier!\n");  */
						return IDENTIFIER; 
					}					
{literal_string}	{	
						vbplval.string = (char *) strdup(yytext+1);   
						if (vbplval.string[yyleng - 2] != (char)34)   
							vbperror("Unterminated string!");	     
						else									     
							vbplval.string[yyleng - 2] = '\0';	     
						vbp_tokenpos += vbpleng; 					     
						/* printf("A string literal!\n"); */
						return LITERAL_STRING;  			
					}
{guid_literal} 			{
							vbplval.string = (char *) strdup(yytext);
							vbp_tokenpos += yyleng;
							/*printf("Got a GUID!");*/
							return LITERAL_GUID;
						}
"*\\G"{guid_literal}	{	
							vbplval.string = (char *) strdup(yytext);
							vbp_tokenpos += yyleng;
							return LITERAL_REFERENCE;
						}
.					{	vbperror("Trying to lex M$'s syntax - give up!\n");
						exit(1); 
					}
%%
vbpwrap()
{
	return 1;
}

    Source: geocities.com/wabbitty2002