added Self token

changed program rule
added rules for box
removed second assign
added storagequalifier
added typedefine
This commit is contained in:
Felix Müller 2024-05-08 15:51:30 +02:00
parent 5604fab87b
commit f05ebf6ac2
2 changed files with 49 additions and 8 deletions

View File

@ -38,6 +38,7 @@
"int" {DEBUG("\"%s\" tokenized with \'KeyInt'", yytext); return(KeyInt);}; "int" {DEBUG("\"%s\" tokenized with \'KeyInt'", yytext); return(KeyInt);};
"float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);}; "float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);};
"self" {DEBUG("\"%s\" tokenized with \'KeySelf\'", yytext); return(KeySelf);};
"as" {DEBUG("\"%s\" tokenized with \'KeyAs'", yytext); return (KeyAs);}; "as" {DEBUG("\"%s\" tokenized with \'KeyAs'", yytext); return (KeyAs);};
"short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);}; "short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);};
"long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);}; "long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);};

View File

@ -13,6 +13,7 @@
%token KeyInt %token KeyInt
%token KeyFloat %token KeyFloat
%token KeySelf
%token KeyAs %token KeyAs
%token <string> ValInt %token <string> ValInt
%token <string> Ident %token <string> Ident
@ -63,15 +64,26 @@
%left OpBitand OpBitor OpBitxor OpBitnot %left OpBitand OpBitor OpBitxor OpBitnot
%% %%
program: statementlist program: program programbody
| fundef; | programbody;
programbody: moduleimport
| fundef
| box
| definition
| decl
| typedef;
expr: ValFloat expr: ValFloat
| ValInt | ValInt
| ValMultistr | ValMultistr
| ValStr | ValStr
| Ident | Ident
| operation; | operation
| boxaccess
| boxselfaccess;
exprlist: expr ',' exprlist exprlist: expr ',' exprlist
| expr; | expr;
@ -98,9 +110,26 @@ IOqualifyier: KeyIn
paramdecl: type ':' Ident { DEBUG("Param-Declaration"); }; paramdecl: type ':' Ident { DEBUG("Param-Declaration"); };
funcall: Ident argumentlist { DEBUG("Function call"); }; box: KeyType KeyBox ':' Ident '{' boxbody '}' { DEBUG("Box"); }
| KeyType KeyBox ':' Ident '{' '}';
assign: Ident '=' expr { DEBUG("Assignment"); }; boxbody: boxbody boxcontent
| boxcontent;
boxcontent: decl { DEBUG("Box decl Content"); }
| definition { DEBUG("Box def Content"); }
| fundef { DEBUG("Box fun Content"); };
boxselfaccess: KeySelf '.' Ident
| KeySelf '.' boxaccess;
boxaccess: Ident '.' Ident
| Ident '.' boxaccess;
boxcall: boxaccess argumentlist
| boxselfaccess argumentlist;
funcall: Ident argumentlist { DEBUG("Function call"); };
moduleimport: KeyImport ValStr { DEBUG("Module-Import"); }; moduleimport: KeyImport ValStr { DEBUG("Module-Import"); };
@ -112,7 +141,8 @@ statement: assign
| definition | definition
| while | while
| branch | branch
| funcall; | funcall
| boxcall;
branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); }; branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); };
branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); }; branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); };
@ -129,15 +159,25 @@ while: KeyWhile expr '{' statementlist '}' { DEBUG("while"); };
identlist: Ident ',' identlist identlist: Ident ',' identlist
| Ident; | Ident;
decl: type ':' identlist; decl: type ':' identlist
| storagequalifier type ':' identlist
definition: decl '=' expr { DEBUG("Definition"); }; definition: decl '=' expr { DEBUG("Definition"); };
assign: Ident '=' expr { DEBUG("Assignment"); }; storagequalifier: KeyGlobal
| KeyStatic
| KeyLocal;
assign: Ident '=' expr { DEBUG("Assignment"); }
| boxaccess '=' expr
| boxselfaccess '=' expr ;
sign: KeySigned sign: KeySigned
| KeyUnsigned; | KeyUnsigned;
typedef: KeyType type':' Ident;
scale: scale KeyShort scale: scale KeyShort
| scale KeyHalf | scale KeyHalf
| scale KeyLong | scale KeyLong