Startpunkten

This commit is contained in:
2026-03-05 13:31:50 +01:00
commit 86a20ae0e1
16 changed files with 1305 additions and 0 deletions

35
Lab2/lexer.l Normal file
View 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);}
%%