parser/lexer.ll
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:57:58 +0100
changeset 6 c3dc3eb3b541
parent 5 d752cbe8208e
child 9 c3fecc82ade6
permissions -rw-r--r--
a small libtool demo added to the demo distribution committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/* 
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
 *  $Id$
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
 * $URL$
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 */
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
%{
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
	#include <stdio.h>
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
	#include "parser.h"
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
%}
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
%%
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
[0-9]+			{ yylval = atoi(yytext); return DIGIT;    }
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
[a-zA-Z]		{ yylval = yytext[0]; return LETTER;      }
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
"+"			return PLUS;	     
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
"-"			return MINUS;       
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
"*"			return MUL;         
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
"/"			return DIV;       
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
"("|")"|"="		return yytext[0]; 
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
[ \t]+			;
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
\n			return yytext[0];
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
.			printf("FEHLER: %s\n", yytext);
d752cbe8208e asm and parser demos added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    23
%%