-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.l
More file actions
33 lines (33 loc) · 941 Bytes
/
Copy pathtest.l
File metadata and controls
33 lines (33 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%{
#include <stdio.h>
#include <stdlib.h>
%}
keyword bolo|pocho|dobara|agar|warna|ruko|khatam|kam
letter [a-zA-Z]
identifier {letter}+
number -?[0-9](\.[0-9]+)?
string \"([^\\\"|\\.])*\"
assignment \=
sum \+
sub \-
terminator \:
modulo \%
operator {sum}|{sub}|{assignment}|{modulo}
error \.{identifier}
%%
{keyword} {printf("%s is a Keyword\n",yytext);}
{identifier} {printf("%s is a identifier\n",yytext);}
{string} {printf("%s is a string\n",yytext);}
{operator} {printf("%s is a operator\n",yytext);}
{number} {printf("%s is a Number\n",yytext);}
{terminator} {printf("%s is a terminator\n",yytext);}
{error} {printf("%s is an Invalid input\n",yytext);}
%%
int yywrap(){}
int main(){
FILE *fp;
fp = fopen("code.us","r");
yyin = fp;
yylex();
return 0;
}