Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "header.h"
- #include "y.tab.h"
- using namespace std;
- int yyerror(char*);
- simple s,t;
- int line_count=1;
- %}
- INCLUDE #include<[a-z]+\.h>
- WS [ \t]+
- DIGIT [0-9]
- NUMBER [-]?{DIGIT}+(\.{DIGIT}+)?
- letter [A-Za-z]
- id (_|{letter})(_|{letter}|{DIGIT})*
- %%
- "(" { return LPAREN; }
- ")" { return RPAREN; }
- "{" { return LCURL; }
- "}" { return RCURL; }
- ";" { return SEMICOLON; }
- "=" { return ASSIGNOP;}
- "\"" { return D_QUOTE; }
- "%d" { return SPECIFIER; }
- "printf" { return PRINTF; }
- "," { return COMMA; }
- "main" {return MAIN;}
- "int" {return INT;}
- "using namespace std;" {}
- "return 0;" {}
- "\n" {line_count++;}
- {id} {
- s.ch=yytext;
- s.d = strlen(s.ch);
- yylval=(YYSTYPE)&s;
- return VARIABLE;}
- {WS} { /* No action and no return */}
- {NUMBER} {
- t.ch=yytext;
- t.d = strlen(t.ch);
- yylval=(YYSTYPE)&t;
- return NUMBER;
- }
- {INCLUDE} {
- return INCLUDE;
- }
- %%
- int yywrap()
- {
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement