Startpunkten
This commit is contained in:
35
Lab2/lexer.l
Normal file
35
Lab2/lexer.l
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Laboration 2 i C och UNIX
|
||||
*
|
||||
* Komplett shell
|
||||
* =========================================
|
||||
*
|
||||
* Christian Ohlsson, di7chro@cse.kau.se
|
||||
* Stefan Sonesson, di7stes@cse.kau.se
|
||||
*
|
||||
* Karlstads Universitet, 991209
|
||||
*
|
||||
*
|
||||
*===========================================
|
||||
*/
|
||||
%{
|
||||
#include "tree.h"
|
||||
#include "y.tab.h"
|
||||
%}
|
||||
|
||||
WORD [a-zA-Z0-9_\-\./\*]+
|
||||
|
||||
%%
|
||||
[ \t]+ {/*Käkar upp white-space*/}
|
||||
"\n" { insert(NULL); return NL;}
|
||||
"&" { insert(NULL); return AND;}
|
||||
"|" { insert(NULL); return PIPE;}
|
||||
";" { insert(NULL); return SEMI;}
|
||||
">" { insert(NULL); return GREAT;}
|
||||
"<" { insert(NULL); return LESS;}
|
||||
">>" { insert(NULL); return DBLARR;}
|
||||
"exit" { printf("OK, use the other stinky shell then...\n");exit(0);}
|
||||
{WORD} { yylval.txt=insert(yytext);return WORD;}
|
||||
. { fprintf(stderr,"What?\n",6);}
|
||||
%%
|
||||
|
||||
Reference in New Issue
Block a user