Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CompilerbauBlatt2
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Oscar Amaya Mohr
CompilerbauBlatt2
Commits
2b44b5aa
Commit
2b44b5aa
authored
2 years ago
by
Oscar Amaya Mohr
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
881263b1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
minako-lexic.l
+62
-0
62 additions, 0 deletions
minako-lexic.l
with
62 additions
and
0 deletions
minako-lexic.l
0 → 100644
+
62
−
0
View file @
2b44b5aa
%option yylineno noyywrap nounput noinput nodefault
%{
#include "minako.h"
extern int fileno(FILE *stream);
void invalid_token() {
fprintf(stderr, "Invalid Token: \"%s\"\n", yytext);
exit(EXIT_FAILURE);
}
%}
%s st
BLOCK_COMMENT "/*"((("*"[^/])?)|[^*])*"*/"
LINE_COMMENT "//".*
INT [0-9]+
FLOAT [0-9]+"."[0-9]+|"."[0-9]+([eE]([-+])?[0-9]+)?|[0-9]+[eE]([-+])?[0-9]+
ID ([a-zA-Z])+([0-9]|[a-zA-Z])*
PUNCTUATION "+"|"-"|"*"|"/"|"="|"("|")"|"{"|"}"|","|";"
WHITESPACE [ \t\n\r]
%%
{BLOCK_COMMENT}
{LINE_COMMENT}
bool return KW_BOOLEAN;
do return KW_DO;
else return KW_ELSE;
float return KW_FLOAT;
for return KW_FOR;
if return KW_IF;
int return KW_INT;
printf return KW_PRINTF;
return return KW_RETURN;
void return KW_VOID;
while return KW_WHILE;
&& return AND;
\|\| return OR;
== return EQ;
!= return NEQ;
\>= return GEQ;
\<= return LEQ;
\> return GRT;
\< return LSS;
{INT} yylval.intValue = atoi(yytext); return CONST_INT;
{FLOAT} yylval.floatValue = atof(yytext); return CONST_FLOAT;
true yylval.intValue = 1; return CONST_BOOLEAN;
false yylval.intValue = 0; return CONST_BOOLEAN;
\" BEGIN(st);
<st>[^\n\"]*/\" yylval.string = yytext; BEGIN(INITIAL);return CONST_STRING;
{ID} yylval.string = yytext; return ID;
{PUNCTUATION} return (int)(*yytext);
{WHITESPACE}
. invalid_token();
<<EOF>> return EOF;
%%
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment