Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listo el compilador #41

Open
wants to merge 204 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
aaf658c
agregando mi nombre y usuario jki
cwjki Mar 1, 2021
b98c481
Datos de Pin
livi98 Mar 1, 2021
dec819f
Peña
cwjki Mar 1, 2021
a61d547
test
livi98 Mar 1, 2021
a10d4bb
esto es una prueba
livi98 Mar 1, 2021
57b45a5
otra prueba
cwjki Mar 1, 2021
6ecbeca
Merge branch 'master' of https://github.com/Pin-y-Pon/cool-compiler-2021
cwjki Mar 1, 2021
0a70bd2
test
cwjki Mar 1, 2021
dda94c3
no funciono lo que queriamos probar
cwjki Mar 1, 2021
f507eaa
lexer.py init
cwjki Sep 5, 2021
a9af1fa
tokens and reserved lexer
cwjki Sep 6, 2021
530b10e
working on lexer.py
cwjki Sep 6, 2021
90a4923
workin on lexer.py
cwjki Sep 14, 2021
88865ff
comments and strings in lexer
cwjki Oct 9, 2021
b02c985
lexer finished, i hope :)
cwjki Oct 10, 2021
01bf9b5
solve conflict in team.yml
cwjki Oct 10, 2021
24d2143
starting ast.py
cwjki Oct 11, 2021
9db81e5
adding some nodes to ast.py
cwjki Oct 11, 2021
c897722
almost finish the ast
cwjki Oct 11, 2021
9a8e430
ast nodes done
cwjki Oct 15, 2021
6a60ca2
starting the parser
cwjki Oct 15, 2021
4ee8e3b
working on the parser
cwjki Oct 16, 2021
bd57ebf
working on parser
cwjki Oct 18, 2021
6d5450f
adding lines and columns in parser
cwjki Oct 18, 2021
c1f6b8b
not finished expr parser
cwjki Oct 18, 2021
4a2131f
parser finished, hope :)
cwjki Oct 19, 2021
039de67
before testing lexer and parser
cwjki Oct 19, 2021
6fb5b21
fixing some names and imports
cwjki Oct 19, 2021
7016996
fixing some typos in parser.py
cwjki Oct 26, 2021
1695462
adding visitor .py
cwjki Oct 26, 2021
3b33651
starting the semantic analyser
cwjki Oct 27, 2021
72acd24
creating semantic types
cwjki Oct 27, 2021
32ce1da
test develop branch
Jan 4, 2022
e3d2432
jki test
Jan 4, 2022
47c4dbb
a
livi98 Jan 4, 2022
a6bcace
Merge branch 'livi' into develop
livi98 Jan 4, 2022
6494d0b
final test git
Jan 4, 2022
7a559e7
fixing typos in lexer.py
Jan 4, 2022
8f5f8cf
fixing warnings in ast.py
Jan 4, 2022
307370f
fixing warnings in parser.py
Jan 5, 2022
74f5d0f
fixed all warning from lexer and parser
Jan 5, 2022
2d23c6e
trying wsl on windows
cwjki Jan 5, 2022
e84b084
cil_ast pag 7 conf hasta arith
livi98 Jan 5, 2022
1c0b7f4
cil_ast pag 11 conf hasta vcall
livi98 Jan 6, 2022
edeae3f
figthing with the imports pylint
Jan 6, 2022
81abcaf
cil_ast complete
livi98 Jan 6, 2022
7e256dd
error in parser uknown location
Jan 6, 2022
205338e
parser folder changed to cparser :(
Jan 6, 2022
38c440c
cil_ast complete 2.0
livi98 Jan 6, 2022
cdbc12b
adding BaseCOOLToCILVisitor
livi98 Jan 6, 2022
660ec91
first test pass manually
cwjki Jan 6, 2022
535baec
COOLToCLIVisitor ProgramNode sin build_in
livi98 Jan 6, 2022
9ffc0a0
adding Atribute and Method class
cwjki Jan 6, 2022
efdbdf0
COOLToCLIVisitor ProgramNode sin build_in 2.0
livi98 Jan 6, 2022
5e768ac
working on the Type class in semantic
cwjki Jan 7, 2022
f072c44
probar los test
cwjki Jan 7, 2022
08aaf01
test2
cwjki Jan 7, 2022
838639c
checking the testing, removing '()' from the error print
cwjki Jan 7, 2022
2f52add
trying to fix the testing
cwjki Jan 7, 2022
9441d45
testing 2
cwjki Jan 7, 2022
dd40b0a
i was passing a single test :(
cwjki Jan 7, 2022
bb51c74
COOLToCLIVisitor fixing ProgramNode 2.0 sin buitl_in
livi98 Jan 7, 2022
e412d4f
trying to fix the test
Jan 10, 2022
298f0ba
fixing the tester 2
cwjki Jan 10, 2022
858e6cc
testing 3
Jan 11, 2022
07d0aca
COOLToCLIVisitor ClassDeclarationNode
livi98 Jan 11, 2022
0c6c1c7
Merge branch 'livi' into develop
livi98 Jan 11, 2022
1573a44
fixing the merge
cwjki Jan 11, 2022
20ac7e9
changing the dashes
cwjki Jan 11, 2022
53499ff
fixing the lineno in lexer
cwjki Jan 11, 2022
1fd5ca8
COOLToCLIVisitor FuncDeclarationNode
livi98 Jan 12, 2022
c8e25d4
COOLToCLIVisitor AttrDeclarationNode
livi98 Jan 12, 2022
c032cb2
COOLToCLIVisitor AssignNode
livi98 Jan 12, 2022
34faa2a
fixing the mixed2.cl test
cwjki Jan 12, 2022
6b18913
all the lexer test pass :)
cwjki Jan 12, 2022
8911632
starting the parser testing
cwjki Jan 12, 2022
32f7baf
parser test 1
cwjki Jan 12, 2022
4fe8de6
testing parser 2
cwjki Jan 13, 2022
0c2550b
LBRACE LPAREN
cwjki Jan 13, 2022
bf197f8
fixing a typo in parser
cwjki Jan 13, 2022
8f30272
COOLToCLIVisitor Nodes FuncCall If While Block
livi98 Jan 13, 2022
42c9d77
COOLToCLIVisitor Nodes Let Case Var New AllBinary
livi98 Jan 15, 2022
f9822f7
sync ubuntu
livi98 Feb 7, 2022
ae880cc
trying to merge
livi98 Feb 7, 2022
a0841ff
lexer test work here
Feb 7, 2022
03e265f
Merge branch 'develop' of https://github.com/Pin-y-Pon/cool-compiler-…
cwjki Feb 8, 2022
4b56cec
Reverting to bf197f86d30876f99b9857b4ede3c5e3e0190ed9
cwjki Feb 8, 2022
b9386a6
new change
livi98 Feb 8, 2022
640cd14
Merge branch 'livi' into develop
livi98 Feb 8, 2022
be42513
In BaseCOOLToCILVisitor adding define_biult_in and in COOLToCILVisito…
livi98 Feb 8, 2022
2731bfb
PrintVisitor for cil
livi98 Feb 9, 2022
7b403b1
separate func_calls (adding member_call) on COLL AST
livi98 Feb 9, 2022
2b42c65
BaseCILToMIPSVisitor first ideas
livi98 Feb 12, 2022
733e8ac
BaseCILToMIPSVisitor and MIPSVisitor real first ideas
livi98 Feb 13, 2022
5720908
fixing so many errors on CILToMIPSVisitor and adding ArithNodes
livi98 Feb 13, 2022
83b3961
type collector done
Feb 14, 2022
4a25f19
typeBuilder done
Feb 14, 2022
407c848
fixing errors on BaseCILToMIPSVisitor and adding AttrNodes
livi98 Feb 14, 2022
f30fe7a
fixing errors on BaseCILToMIPSVisitor 2.0
livi98 Feb 14, 2022
d453174
fixing errors 3.0
livi98 Feb 15, 2022
befc5c4
finished the typeChecker
Feb 15, 2022
1978914
fixing errors 4.0 + adding Substring and Concat Nodes on CILToMIPSVis…
livi98 Feb 16, 2022
214adfd
before merge jki
Feb 18, 2022
9a9aeda
Merge branch 'jki' into develop
cwjki Feb 18, 2022
9ce0abc
trying to fix programcl1 test in parser
cwjki Feb 18, 2022
c9824d2
no funciono
cwjki Feb 18, 2022
fc834de
hope this fix the parser errors
cwjki Feb 18, 2022
1e8a8df
fix program1.cl parser test, tryint to test mixed1.cl
cwjki Feb 18, 2022
d4afb53
all the parser test are pass, next step fix the semantic tests
cwjki Feb 18, 2022
581e507
fixing some bugs in the Context class
cwjki Feb 18, 2022
5d71a61
before modify the ast
cwjki Feb 18, 2022
be19abd
fixing some index in parser
cwjki Feb 18, 2022
0899ee5
testing
cwjki Feb 18, 2022
9908407
fixing a little typo in typeCollector
cwjki Feb 19, 2022
571e97e
fixing some typos in TypeBuilder
cwjki Feb 19, 2022
cd49676
adding positions to params
cwjki Feb 19, 2022
4466c3c
changing str for lexToken to save the position of params
cwjki Feb 19, 2022
a563e66
separate dotcall and arrobacall
cwjki Feb 20, 2022
3a63f68
retesting parser and lexer
cwjki Feb 20, 2022
74b2988
fixing a typo in BlockNode
cwjki Feb 20, 2022
3d6c9ae
fixing typebuilder in semantics
cwjki Feb 20, 2022
cb0d2d1
fixing some typos on Context and Scope classes
cwjki Feb 20, 2022
aedea12
adding var declaration to the parser logic
cwjki Feb 20, 2022
b70963a
adding to the varCollector the varDeclarationNode logic
cwjki Feb 20, 2022
9e73493
changing the structure of varCollector hope its work
cwjki Feb 20, 2022
1d8308b
trying to pass the semantic tests
cwjki Feb 20, 2022
79aafd1
deleting unneccesary files
cwjki Feb 20, 2022
efe1f45
fixing func_calls
livi98 Feb 20, 2022
19574af
fixing the imports
cwjki Feb 20, 2022
367eba9
fixing more imports
cwjki Feb 21, 2022
2fe632e
Merge branch 'livi' into develop
livi98 Feb 21, 2022
87979eb
adding AutoType
cwjki Feb 21, 2022
6a019dd
changing almost everything in typeChecker :(
cwjki Feb 21, 2022
48c1e29
adding arroba and dot callNodes on COOLToCILVisitor
livi98 Feb 21, 2022
e206a49
changing the logic of the functions calls
cwjki Feb 21, 2022
3839191
testing semantic errors
cwjki Feb 21, 2022
7605ee9
fixing a typo
cwjki Feb 21, 2022
26612be
testing again semantics
cwjki Feb 21, 2022
2c61907
restesting the semantic
cwjki Feb 21, 2022
27589b5
fixing some typos bugs
cwjki Feb 21, 2022
801e64a
testign semantics test after fixing some bugs
cwjki Feb 21, 2022
4016767
fixign the attribute 4 semantic test
cwjki Feb 21, 2022
711e4ed
check attibute 4 again
cwjki Feb 22, 2022
160707a
test if loop1 semantic works
cwjki Feb 22, 2022
6e42935
modificating precedence
cwjki Feb 22, 2022
ed128ad
handling void types
cwjki Feb 22, 2022
880d7f1
fixing a aritmethid 9, a f** typo
cwjki Feb 22, 2022
583b649
all the semantic test passed, trying to pass the code generating
cwjki Feb 22, 2022
cb8aa1e
test
cwjki Feb 22, 2022
5001898
test 2
cwjki Feb 22, 2022
12f742b
deleting a duplicate method
cwjki Feb 22, 2022
c77f51b
deleting unnecessary imports
cwjki Feb 22, 2022
018f686
Merge branch 'develop' of https://github.com/Pin-y-Pon/cool-compiler-…
livi98 Feb 22, 2022
15ae070
separating the str int prints and reads
livi98 Feb 22, 2022
27184fa
adding CopyNode cil ast
livi98 Feb 22, 2022
64bbc5f
modificating graph in context
livi98 Feb 22, 2022
0fb6748
adding string comparison
livi98 Feb 22, 2022
5fcfd55
adding computed_type
livi98 Feb 23, 2022
fa2c1cf
fixing a typo
livi98 Feb 23, 2022
c221e63
fixing while node and ifThenElse condition
livi98 Feb 23, 2022
269bc2d
fixing binary expr nodes
livi98 Feb 23, 2022
6bd2864
fixing let declaration variables in cil
livi98 Feb 23, 2022
345a87a
still have an error in case nodes
livi98 Feb 23, 2022
2f6b6d0
adding formatter
cwjki Feb 23, 2022
7e0d758
changing all binary operations nodes to the same one
livi98 Feb 23, 2022
d20da2c
fixing label and go to
livi98 Feb 23, 2022
9a2ce97
check the test again
livi98 Feb 23, 2022
caef4af
rechecking the test
livi98 Feb 23, 2022
52a9210
fixing string equals
livi98 Feb 23, 2022
d4bae9d
handling string and int load and read separatly
livi98 Feb 23, 2022
2e7dce2
testing code gen
livi98 Feb 23, 2022
6387265
fixing get_type
livi98 Feb 23, 2022
99614e5
testing
livi98 Feb 23, 2022
172c4be
fixing a bug in memberCall
livi98 Feb 23, 2022
6b6d14c
hoping hello worrld works
livi98 Feb 23, 2022
2287d39
retesting code gen
livi98 Feb 23, 2022
799cf58
retesting
livi98 Feb 23, 2022
cf42ed7
hello world test passed, checking print cool
livi98 Feb 23, 2022
3e93f94
retesting print cool
livi98 Feb 23, 2022
c2a4abc
testing fib
livi98 Feb 24, 2022
6bc3200
cahnging not and xor
livi98 Feb 24, 2022
e329396
changing again xor and neg
livi98 Feb 24, 2022
425bb5b
fixing a bug in get_attributte
cwjki Feb 24, 2022
c19f835
7/17 codegen pass
cwjki Feb 24, 2022
36a2e9e
trying to fix primes.cl test
cwjki Feb 24, 2022
b8036be
having trouble with the parent of built in
cwjki Feb 24, 2022
44aaaca
again
cwjki Feb 24, 2022
a55433d
checking parent of built in
cwjki Feb 24, 2022
a77ffe1
rechecking parent of built in
cwjki Feb 24, 2022
cecd267
problem solve
cwjki Feb 24, 2022
b97e669
testing void
cwjki Feb 24, 2022
035eab3
changing neg y xor cil
cwjki Feb 24, 2022
4c2d399
handlign void types
cwjki Feb 24, 2022
bda9e37
fixing a bug in parents
cwjki Feb 24, 2022
885ab89
no funciono lo anterior
cwjki Feb 24, 2022
6f2e89a
fixing a typo with self type
cwjki Feb 24, 2022
32bef4f
fixing the case graph
cwjki Feb 24, 2022
5cc9ff3
have a problem printing string
cwjki Feb 24, 2022
9667b1c
retest
cwjki Feb 24, 2022
1782916
printing a \t de mas
cwjki Feb 24, 2022
65fd701
fix the f /t problem, hope all test pass
cwjki Feb 24, 2022
45da2b0
ALL TEST PASSED, deleting some comments and useless imports
cwjki Feb 24, 2022
6baf39e
deleting unneccesary files
cwjki Feb 25, 2022
129685f
adding report.pdf
livi98 Feb 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[MASTER]
disable=C0114, # missing-module-docstring
disable=C0115,
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"prettier.useTabs": true,
"editor.formatOnSave": true
}
Binary file added doc/report.pdf
Binary file not shown.
16 changes: 7 additions & 9 deletions doc/team.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
members:
- name: Nombre Apellido1 Apellido2
github: github_id
group: CXXX
- name: Nombre Apellido1 Apellido2
github: github_id
group: CXXX
- name: Nombre Apellido1 Apellido2
github: github_id
group: CXXX
- name: Olivia Gonzalez Peña
github: livi98
group: C411
- name: Juan Carlos Casteleiro Wong
github: cwjki
group: C411

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
pytest-ordering
ply
Empty file added src/__init__.py
Empty file.
45 changes: 45 additions & 0 deletions src/code_generator/BaseCILToMIPSVisitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

class BaseCILToMIPSVisitor:
def __init__(self):
self.mips_code = ''
self.text = ''
self.data = ''
self.mips_operators = {
'+': 'add',
'-': 'sub',
'*': 'mul',
'/': 'div',
'<': 'slt',
'<=': 'sle',
'=': 'seq',
}
self.current_function = None
self.types = None
self.attr_offset = {}
self.method_offset = {}
self.var_offset = {}
self.runtime_errors = {}
self.register_runtime_errors()

def is_param(self, name):
return name in self.current_function.params

def register_runtime_errors(self):
self.runtime_errors[
'dispatch_void'] = 'Runtime Error: A dispatch (static or dynamic) on void'
self.runtime_errors['case_void'] = 'Runtime Error: A case on void'
self.runtime_errors['case_no_match'] = 'Runtime Error: Execution of a case statement without a matching branch'
self.runtime_errors['div_zero'] = 'Runtime Error: Division by zero'
self.runtime_errors['substr'] = 'Runtime Error: Substring out of range'
self.runtime_errors['heap'] = 'Runtime Error: Heap overflow'
for error in self.runtime_errors:
self.data += f'{error}: .asciiz "{self.runtime_errors[error]}"\n'
self.generate_runtime_error(error)

def generate_runtime_error(self, error):
self.text += f'{error}_error:\n'
self.text += f'la $a0 {error}\n'
self.text += f'li $v0, 4\n'
self.text += 'syscall\n'
self.text += 'li $v0, 10\n'
self.text += 'syscall\n'
Loading