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
4542b9c5
Commit
4542b9c5
authored
Dec 31, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added command line options to main.py.
parent
aeb435c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
main.py
main.py
+30
-10
run
run
+2
-2
No files found.
main.py
View file @
4542b9c5
...
...
@@ -4,24 +4,44 @@ from sys import argv, exit
from
src.parser
import
parse_file
verbose_level
=
2
options
=
{
'-v'
:
1
}
# Parse arguments
if
len
(
argv
)
<
2
:
print
'Usage: python %s
SOURCE_FILE [ OUT_FILE [ SOURCE_OUT_FILE ] ]'
\
%
argv
[
0
]
def
exit_with_usage
()
:
print
'Usage: python %s
[ options ] SOURCE_FILE'
%
argv
[
0
]
print
'options: -i SOURCE_OUT_FILE | -o OUT_FILE | -v VERBOSE_LEVEL'
exit
(
1
)
if
len
(
argv
)
%
2
:
exit_with_usage
()
elif
len
(
argv
)
>
2
:
values
=
argv
[
2
:
-
1
:
2
]
if
argv
[
1
][
0
]
!=
'-'
:
exit_with_usage
()
for
i
,
option
in
enumerate
(
argv
[
1
:
-
1
:
2
]):
if
option
not
in
[
'-i'
,
'-o'
,
'-v'
]:
print
'unknown option "%s"'
%
option
exit
(
1
)
if
i
>=
len
(
values
):
print
'No value given for option "%s"'
%
option
exit
(
1
)
options
[
option
]
=
values
[
i
]
# Parse file
program
=
parse_file
(
argv
[
1
])
program
.
verbose
=
verbose_level
program
=
parse_file
(
argv
[
-
1
])
program
.
verbose
=
int
(
options
[
'-v'
])
# Save input assembly in new file for easy comparison
if
len
(
argv
)
>
3
:
program
.
save
(
argv
[
3
])
if
'-i'
in
options
:
program
.
save
(
options
[
'-i'
])
# Perform optimizations
...
...
@@ -29,5 +49,5 @@ program.optimize()
# Save output assembly
if
len
(
argv
)
>
2
:
program
.
save
(
argv
[
2
])
if
'-o'
in
options
:
program
.
save
(
options
[
'-o'
])
run
View file @
4542b9c5
#!/bin/sh
python main.py
benchmarks/build/
$1
.s out.s
in
.s
&&
meld
in
.s out.s
#!/bin/
ba
sh
python main.py
-v
${
2
-1
}
-i
in
.s
-o
out.s benchmarks/build/
$1
.s
&&
meld
in
.s out.s
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