Added the keywards and types t#01
This commit is contained in:
BIN
lexicalStructure
Executable file
BIN
lexicalStructure
Executable file
Binary file not shown.
@ -2,11 +2,40 @@
|
|||||||
/* so we placed the citation here. */
|
/* so we placed the citation here. */
|
||||||
/* definitions */
|
/* definitions */
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
%{
|
%{
|
||||||
#include <typedefs.h>
|
#include "typedefs.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
//rules
|
|
||||||
|
.|\n
|
||||||
|
"integer" {printf("T_INTEGER %s, Token %d\n",yytext, T_INTEGER);} //{return T_INTEGER}
|
||||||
|
"address" {printf("T_ADDRESS %s, Token %d\n",yytext, T_ADDRESS);} //{return T_ADDRESS}
|
||||||
|
"Boolean" {printf("T_BOOLEAN %s, Token %d\n",yytext, T_BOOLEAN);} //{return T_BOOLEAN}
|
||||||
|
"character" {printf("T_CHARACTER %s, Token %d\n",yytext, T_CHARACTER);} //{return T_CHARACTER}
|
||||||
|
"string" {printf("T_STRING %s, Token %d\n",yytext, T_STRING);} //{return T_STRING}
|
||||||
|
|
||||||
|
/* KEYWARDS */
|
||||||
|
|
||||||
|
|
||||||
|
"while" {printf("WHILE %s, Token %d\n",yytext, WHILE);} //{return WHILE}
|
||||||
|
"if" {printf("IF %s, Token %d\n",yytext, IF);} //{return IF}
|
||||||
|
"then" {printf("THEN %s, Token %d\n",yytext, THEN);} //{return THEN}
|
||||||
|
"else" {printf("ELSE %s, Token %d\n",yytext, ELSE);} //{return ELSE}
|
||||||
|
"type" {printf("TYPE %s, Token %d\n",yytext, TYPE);} //{return TYPE}
|
||||||
|
"function" {printf("FUNCTION %s, Token %d\n",yytext, FUNCTION);} //{return FUNCTION}
|
||||||
|
"return" {printf("RETURN %s, Token %d\n",yytext, RETURN);} //{return RETURN}
|
||||||
|
"external" {printf("EXTERNAL %s, Token %d\n",yytext, EXTERNAL);} //{return EXTERNAL}
|
||||||
|
"as" {printf("AS %s, Token %d\n",yytext, AS);} //{return AS}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
//user code
|
int main(int argc, char *argv[]){
|
||||||
|
argc--, argv++;
|
||||||
|
if ( argc > 0 )
|
||||||
|
yyin = fopen( argv[0], "r" );
|
||||||
|
else
|
||||||
|
yyin = stdin;
|
||||||
|
yylex();
|
||||||
|
}
|
||||||
|
29
tests/test_keywards.alpha
Normal file
29
tests/test_keywards.alpha
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
while
|
||||||
|
While
|
||||||
|
whiLe
|
||||||
|
if
|
||||||
|
IF
|
||||||
|
If
|
||||||
|
iF
|
||||||
|
then
|
||||||
|
Then
|
||||||
|
theN
|
||||||
|
else
|
||||||
|
eLse
|
||||||
|
elSe
|
||||||
|
Else
|
||||||
|
type
|
||||||
|
Type
|
||||||
|
tyPe
|
||||||
|
function
|
||||||
|
Function
|
||||||
|
functioN
|
||||||
|
return
|
||||||
|
Return
|
||||||
|
returN
|
||||||
|
external
|
||||||
|
External
|
||||||
|
exteRnal
|
||||||
|
as
|
||||||
|
As
|
||||||
|
aS
|
10
tests/test_types.alpha
Normal file
10
tests/test_types.alpha
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
integer
|
||||||
|
Integer
|
||||||
|
address
|
||||||
|
Address
|
||||||
|
Boolean
|
||||||
|
boolean
|
||||||
|
character
|
||||||
|
Character
|
||||||
|
string
|
||||||
|
String
|
Reference in New Issue
Block a user