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
cf25e404
Commit
cf25e404
authored
Nov 24, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed useless generator file.
parent
c3ba2d2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
37 deletions
+0
-37
src/generate_grammar.py
src/generate_grammar.py
+0
-37
No files found.
src/generate_grammar.py
deleted
100755 → 0
View file @
c3ba2d2d
#!/usr/bin/python
argmap
=
{
'REG'
:
'WORD'
}
def
command
(
name
,
args
):
"""Generate grammar code to be pasted in grammar.y for a sinle MIPS
command."""
argc
=
len
(
args
)
mapped_args
=
[
argmap
[
arg
]
if
arg
in
argmap
else
arg
for
arg
in
args
]
code
=
'"%s" %s {
\
n
'
%
(
name
,
' COMMA '
.
join
(
mapped_args
))
code
+=
'
\
t
\
t
char **argv = (char **)malloc(%d * sizeof(char *));
\
n
'
%
argc
code
+=
'
\
t
\
t
int *argt = (int *)malloc(%d * sizeof(int));
\
n
'
%
argc
for
i
,
argtype
in
enumerate
(
args
):
code
+=
'
\
t
\
t
argv[%d] = $%d;
\
n
'
%
(
i
,
i
*
2
+
2
)
code
+=
'
\
t
\
t
argt[%d] = ARG_%s;
\
n
'
%
(
i
,
argtype
)
code
+=
'
\
t
\
t
add_line(TYPE_CMD, %s, %d, argv, argt);
\
n
'
%
(
name
,
argc
)
code
+=
'
\
t
}
\
n
'
return
code
# Define commands
commands
=
[
\
([
'add'
,
'sub'
],
[
'REG'
]
*
3
),
\
([
'addi'
,
'subi'
],
[
'REG'
,
'REG'
,
'INT'
]),
\
]
# Generate 'command' grammar
cmd
=
[]
for
names
,
args
in
commands
:
for
name
in
names
:
cmd
.
append
(
command
(
name
,
args
))
code
=
'commands:
\
n
\
t
%s
\
t
;
\
n
'
%
'
\
t
| '
.
join
(
cmd
)
print
code
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