Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
peephole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
peephole
Commits
c14e76cf
Commit
c14e76cf
authored
Nov 16, 2011
by
Jayke Meijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
worked on Lex and Yacc.
parent
1573e930
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
src/Makefile
src/Makefile
+1
-1
src/lex.l
src/lex.l
+7
-5
src/lex_out.y
src/lex_out.y
+3
-1
No files found.
src/Makefile
View file @
c14e76cf
...
...
@@ -3,7 +3,7 @@ LEX=lex
YACC
=
yacc
CFLAGS
=
-ll
parser
:
lex yacc
parser
:
yacc lex
$(CC)
-c
lex.yy.c y.tab.c
$(CC)
-o
$@
lex.yy.o y.tab.o
$(CFLAGS)
...
...
src/lex.l
View file @
c14e76cf
...
...
@@ -2,15 +2,17 @@
#include <stdio.h>
#include "y.tab.h"
%}
arg \$[a-zA-Z0-9\.]+
%%
[a-z0-9$._]+: { yylval.sval = yytext; return LABEL; } /* Label */
\$[a-z0-9._] { yylval.sval = yytext; return ARG; } /* Arg of instr */
^[a-z.]+ { yylval.sval = yytext; return INSTR; } /* Instruction */
#[^\n]* { yylval.sval = yytext; return COMMENT; } /* Comment */
[a-zA-Z0-9$\.]+: { yylval.sval = yytext; return LABEL; } /* Label */
{arg} { yylval.sval = yytext; return ARG; } /* Arg of instr */
[0-9]+(\({arg}\))? { yylval.sval = yytext; return ARG; } /* Arg of instr */
\.[^\n]* { yylval.sval = yytext; return DIRECTIVE; } /* Assembly */
[a-z\.]+ { yylval.sval = yytext; return INSTR; } /* Instruction */
[,] { return COMMA; } /* Comma */
#[^\n]* { yylval.sval = yytext; return COMMENT; } /* Comment */
[\n] { return NL; } /* New line */
[
\s\t]+ { ; }
/* Ignore whitespace */
[
\t]+ { ; }
/* Ignore whitespace */
src/lex_out.y
View file @
c14e76cf
...
...
@@ -17,8 +17,10 @@ void yyerror(char*);
%token <sval> COMMENT
%%
symb:
LABEL {printf("Found a label: %s\n", $1);}
symb symb
| LABEL {printf("Found a label: %s\n", $1);}
| ARG {printf("Found an argument: %s\n", $1);}
| INSTR {printf("Found an instruction: %s\n", $1);}
| DIRECTIVE {printf("Found a directive: %s\n", $1);}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment