All pastes #366381 Raw Edit

Someone

public text v1 · immutable
#366381 ·published 2007-02-21 17:24 UTC
rendered paste body
lexer:

%{
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include "wxfbt_parser.h"
#include "test1.tab.h"
%}

%option noyywrap
%option always-interactive

prefix		^[ \t]*%

%%

<<EOF>>				yyterminate();

{prefix}-.*$			yylval.s_value = new std::string(yytext); return COMMENT;
{prefix}var			return VAR;
{prefix}set			return SET;
{prefix}if				return IF;
{prefix}else			return ELSE;
{prefix}end_if			return END_IF;
{prefix}embed			return EMBED;
{prefix}at				return AT;
{prefix}atstart			return ATSTART;
{prefix}atend			return ATEND;
{prefix}end_at			return END_AT;
{prefix}cache				return CACHE;
{prefix}commit				return COMMIT;
{prefix}rollback			return ROLLBACK;
{prefix}end_cache			return END_CACHE;

{prefix}template			return TEMPLATE;
{prefix}object_classes		return OBJECT_CLASSES;
{prefix}end_template		return END_TEMPLATE;

"<="				return LE;
">="				return GE;
"=="				return EQ;
"!="				return NE;
"<"					return LT;
">"					return GT;
"+"					return OP_PLUS;
"-"					return OP_MINUS;
"*"					return OP_MUL;
"/"					return OP_DIV;
"%"					return OP_MOD;

[a-zA-Z_][0-9a-zA-Z_]*		yylval.s_value = new std::string(yytext); return LABEL;
^[ \t]*$					yylval.s_value = new std::string(yytext); return TEXT;
^[ \t]*[^% \t\n][^\n]*$		yylval.s_value = new std::string(yytext); return TEXT;
[ \t]*\n				yylval.s_value = new std::string(yytext); return REST_OF_LINE;

[0-9]+				{ yylval.r_value = atof(yytext); return NUMBER; }
.	{}

%%