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
6a05c158
Commit
6a05c158
authored
Nov 19, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added COMMA to grammar rule.
parent
4303e97c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
src/grammar.y
src/grammar.y
+12
-11
No files found.
src/grammar.y
View file @
6a05c158
...
...
@@ -9,8 +9,10 @@
#define TYPE_CMD 3
// Argument types
#define ARG_REG 0
#define ARG_OFFSET 1
#define ARG_INT 0
#define ARG_REG 1
#define ARG_LABEL 2
#define ARG_OFFSET 3
typedef struct line {
int type;
...
...
@@ -40,21 +42,19 @@ line *first_line, *last_line;
%token <sval> COMMENT DIRECTIVE WORD LABEL OFFSET CMD
%start symbol
%type <sval>
reg3
%type <sval>
command
%%
reg3: "add" | "sub"
command:
reg3 WORD WORD
WORD {
char *
argv[]
= (char **)malloc(3 * sizeof(char *));
char *argt[]
= (int *)malloc(3 * sizeof(int));
"add" WORD COMMA WORD COMMA
WORD {
char *
*argv
= (char **)malloc(3 * sizeof(char *));
int *argt
= (int *)malloc(3 * sizeof(int));
argv[0] = $2;
argv[1] = $
3
;
argv[2] = $
4
;
argv[1] = $
4
;
argv[2] = $
6
;
argt[2] = argt[1] = argt[0] = ARG_REG;
add_line(TYPE_CMD,
(char *)$1
, 3, argv, argt);
add_line(TYPE_CMD,
"add"
, 3, argv, argt);
}
;
...
...
@@ -107,6 +107,7 @@ void yyerror(char *s)
void add_line(int type, const char *name, int argc, char **argv, int *argt) {
line *l = (line*)malloc(sizeof(line));
printf("\nName: %s\n\n", name);
l->argc = argc;
l->argv = argv;
...
...
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