Skip to content

Proyecto cmp #13

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

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
2b80744
"Lexer and Parser tests passed"
mavaldivie Feb 24, 2021
555acb0
Semantic Test Passed
ClaudiaOM Feb 25, 2021
7d87661
Informacion del equipo y cambios en la organizacion
mavaldivie Mar 1, 2021
a5bcd94
Agregada la dependencia de Ply
mavaldivie Mar 1, 2021
268a87b
Arreglados algunos errores en Semantic.py
mavaldivie Mar 2, 2021
e5ffd5a
Arreglados algunos bugs e implementado el visitor de COOL para CIL
mavaldivie Apr 27, 2021
7f244d2
Arreglados algunos errores en CoolToCilVisitor.py
mavaldivie Aug 22, 2021
ce51935
Implemented some of the methods in the CILtoMIPS visitor.
mavaldivie Nov 27, 2021
7115995
Implemented most of the methods in CILtoMIPS visitor.
mavaldivie Feb 9, 2022
f88d04d
Finished CILtoMIPS visitor.
mavaldivie Feb 11, 2022
64dc8f9
Line and column for CIL Classes
ClaudiaOM Feb 12, 2022
9a90fc8
Created MIPSAstFormatter file and class
mavaldivie Feb 12, 2022
57bffe6
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 12, 2022
454abd4
Fixed bugs
mavaldivie Feb 12, 2022
64c4ed0
Created MIPS formatter class
mavaldivie Feb 13, 2022
a684a7c
Implemented MIPSAstFormatter
ClaudiaOM Feb 14, 2022
58e00e3
Implemented debug line and column for CilToMips
ClaudiaOM Feb 15, 2022
b36bee8
Fixed bug in Parser
mavaldivie Feb 15, 2022
874ce41
Merge branches 'Claudia' and 'Marcos' of https://github.com/NinjaProg…
ClaudiaOM Feb 15, 2022
fca9c51
Fixed bug with LabelNode in GotoNode.label
ClaudiaOM Feb 15, 2022
bc2ef47
Fixed small bug in line and column in debug for Mips
ClaudiaOM Feb 15, 2022
ac9e333
Fixed stype bug in FunctionCallNode in CooltoCilVisitor
ClaudiaOM Feb 15, 2022
04352fa
Fixed depth bug in ClassDeclarationNode in TypeChecker
ClaudiaOM Feb 15, 2022
662821f
Fixed depth bug in ClassDeclarationNode in TypeBuilder for IO,String,…
ClaudiaOM Feb 15, 2022
8ded685
Fixed self bug in FunctionCallNode
ClaudiaOM Feb 15, 2022
f77ba45
Fixed bug
ClaudiaOM Feb 16, 2022
250b2a4
Print line and column Mips Formatter
ClaudiaOM Feb 16, 2022
54ffa32
Fixed bug with attribute declarations
mavaldivie Feb 16, 2022
844877f
Fixed bug with attribute declarations and herency
mavaldivie Feb 16, 2022
0b89bb9
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 16, 2022
2a95c2d
Fixed bugs with line comments in MIPS formatter class
mavaldivie Feb 16, 2022
53008f0
Fixed bugs while printing mips code
mavaldivie Feb 16, 2022
beef9a7
Added types formats to MIPS Formatter class
ClaudiaOM Feb 17, 2022
8416d7a
Added mips_basics.asm file
ClaudiaOM Feb 17, 2022
5aaec0a
Fixed bug of line and column in ResultNode
ClaudiaOM Feb 17, 2022
d2874e5
Fixed comments in mips code
mavaldivie Feb 17, 2022
012468d
Added JumpRegister and MoveLow Nodes
mavaldivie Feb 17, 2022
5000a5e
Fixed initial Data Pointer
mavaldivie Feb 17, 2022
253c66b
Fixed malloc to use v1 register
mavaldivie Feb 17, 2022
fe26699
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 17, 2022
d26f394
Merge remote-tracking branch 'origin/Marcos' into Claudia
ClaudiaOM Feb 17, 2022
7f0faa0
Fixed bugs in code generation
mavaldivie Feb 17, 2022
918dc71
Merge remote-tracking branch 'origin/Marcos' into Claudia
ClaudiaOM Feb 17, 2022
14b21ca
Fixed bugs with stack manipulation
ClaudiaOM Feb 17, 2022
0d43fd8
Added equal_str procedure
ClaudiaOM Feb 18, 2022
38b990e
Added MoveHigh Node and fixed bugs
ClaudiaOM Feb 18, 2022
9f3c6bc
Implemented read_string default procedure
mavaldivie Feb 18, 2022
c863015
Fixed SUBSTR procedure
ClaudiaOM Feb 18, 2022
841932c
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 18, 2022
4f891c8
Merge remote-tracking branch 'origin/Marcos' into Claudia
ClaudiaOM Feb 18, 2022
c68fe2d
Implemented Fixed set attribute workflow in CoolToCilVisitor
mavaldivie Feb 18, 2022
5f180b2
Fixed bug with Int wrapper in SubstringNode
mavaldivie Feb 18, 2022
9fc0985
Fixed bug with read_string procedure
mavaldivie Feb 18, 2022
d6596ad
Changed Malloc to multiple of 4
ClaudiaOM Feb 18, 2022
05d42e9
Merge remote-tracking branch 'origin/Marcos' into Claudia
ClaudiaOM Feb 18, 2022
c5501a1
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 18, 2022
0f48733
fixup! Fixed SUBSTR procedure
ClaudiaOM Feb 18, 2022
2a4a2d7
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 18, 2022
48e8a6f
Fixed type herency
mavaldivie Feb 18, 2022
ee8d01f
Fixed up when accesing attributes
ClaudiaOM Feb 19, 2022
f1796e3
Fixed not Node in Mips
mavaldivie Feb 19, 2022
4e22e80
Returning the object location on method init_attributes
mavaldivie Feb 19, 2022
6ac9833
Fixed bug when setting attribute location
mavaldivie Feb 19, 2022
71008de
Fixed assignment to class attributes
mavaldivie Feb 20, 2022
20f061a
Fixed malloc to use syscall 9
mavaldivie Feb 20, 2022
987d2b0
Fixed graph_input
mavaldivie Feb 21, 2022
3ff82d0
Fixed read_string procedure to use the new malloc
mavaldivie Feb 21, 2022
373dc6d
Fixed default variable declaration nodes
mavaldivie Feb 21, 2022
2ca2d50
Fixed bug in concat procedure
mavaldivie Feb 22, 2022
613e898
Removed TODOs
mavaldivie Feb 22, 2022
e9e7ca4
Begin Readme
ClaudiaOM Feb 22, 2022
79f2047
Fix read end of file in read_str mips_code
ClaudiaOM Feb 23, 2022
64d8640
Merge branch 'Marcos' of /home/adrian/PycharmProjects/cool-compiler-2…
mavaldivie Feb 23, 2022
e5f6d75
Merge remote-tracking branch 'origin/Claudia' into Marcos
mavaldivie Feb 23, 2022
42f70ad
Fixed codegen test to its original state
mavaldivie Feb 23, 2022
f22da46
Update Readme
ClaudiaOM Feb 23, 2022
1773168
Added divide by zero runtime exception
mavaldivie Feb 23, 2022
a51ca71
Update Readme.
ClaudiaOM Feb 23, 2022
44a8c17
Merge remote-tracking branch 'origin/Marcos' into Claudia
ClaudiaOM Feb 23, 2022
d7eb709
Update Readme.
ClaudiaOM Feb 23, 2022
27c1d0f
Update Readme an requirements.txt
ClaudiaOM Feb 24, 2022
61375f2
Added info to Readme file
ClaudiaOM Feb 24, 2022
fbd42d9
Refactored folders and file names
ClaudiaOM Feb 24, 2022
bfc6d9d
Reformated code and files
ClaudiaOM Feb 24, 2022
3e2f2d8
Update Readme
ClaudiaOM Feb 25, 2022
a8499c4
Final Readme update.
ClaudiaOM Feb 25, 2022
bf51c41
Added virtual calls and boxing-unboxing sections to README file
mavaldivie Mar 8, 2022
7568e6d
Added explanation to virtual calls section
mavaldivie Mar 8, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,4 @@ dmypy.json

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

/src/code.cl
448 changes: 428 additions & 20 deletions doc/Readme.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions doc/team.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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: Marcos Adrian Valdivie Rodriguez
github: mavaldivie
group: C412
- name: Claudia Olavarrieta Martinez
github: ClaudiOM
group: C411
- name: Adrian Hernandez Perez
github: AdrianHP
group: C411
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
pytest-ordering
ply>=3.11
pydot>=1.4.2
pytest>=7.0.1
75 changes: 75 additions & 0 deletions src/Main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from core.lexer.Lexer import Lexer
from core.parser.Parser import CoolParser
from core.tools.Evaluation import evaluate_reverse_parse
from core.semantic.TypeCollector import Type_Collector
from core.semantic.TypeBuilder import Type_Builder
from core.semantic.TypeChecker import Type_Checker
from core.cil.CoolToCilVisitor import COOLToCILVisitor
from core.mips.CilToMipsVisitor import CILToMIPSVisitor
from core.mips.MipsAstFormatter import MIPSAstFormatter


def main(args):
try:
with open(args.file, 'r') as fd:
code = fd.read()
except Exception as e:
print(f"(0,0) - CompilerError: {e.args}")
print(args.file)
exit(1)

lexer = Lexer()
tokens = lexer.tokenize(code)
for t in lexer.errors:
print(t)
if any(lexer.errors): exit(1)

productions, operations = CoolParser(tokens)
for e in CoolParser.errors:
print(e)
if any(CoolParser.errors): exit(1)
COOLast = evaluate_reverse_parse(productions, operations, tokens)

type_Collector = Type_Collector()
type_Collector.visit(COOLast)
for e in type_Collector.errors:
print(e)
if any(type_Collector.errors): exit(1)
context = type_Collector.Context

type_Builder = Type_Builder(context)
type_Builder.visit(COOLast)
for e in type_Builder.errors:
print(e)
if any(type_Builder.errors): exit(1)

type_Checker = Type_Checker(context)
scope = type_Checker.visit(COOLast)
for e in type_Checker.errors:
print(e)
if any(type_Checker.errors): exit(1)

CILVisitor = COOLToCILVisitor(type_Checker.Context)
CILast = CILVisitor.visit(COOLast, scope)

MIPSVisitor = CILToMIPSVisitor()
MIPSAst = MIPSVisitor.visit(CILast)
MIPSFormatter = MIPSAstFormatter()
mipsCode = MIPSFormatter.visit(MIPSAst)

out_file = args.file.split(".")
out_file[-1] = "mips"
out_file = ".".join(out_file)

with open(out_file, 'w') as f:
f.write(mipsCode)


if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser(description='CoolCompiler pipeline')
parser.add_argument('-f', '--file', type=str, default='code.cl', help='file to read')

args = parser.parse_args()
main(args)
10 changes: 6 additions & 4 deletions src/coolc.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Incluya aquí las instrucciones necesarias para ejecutar su compilador
#!/bin/bash

INPUT_FILE=$1
OUTPUT_FILE=${INPUT_FILE:0: -2}mips

# Si su compilador no lo hace ya, aquí puede imprimir la información de contacto
echo "LINEA_CON_NOMBRE_Y_VERSION_DEL_COMPILADOR" # TODO: Recuerde cambiar estas
echo "Copyright (c) 2019: Nombre1, Nombre2, Nombre3" # TODO: líneas a los valores correctos
echo "CMA COOL COMPILER v1.0"
echo "Copyright (c) 2019: Marcos Valdivie, Claudia Olavarrieta, Adrian Hernandez"

# Llamar al compilador
echo "Compiling $INPUT_FILE into $OUTPUT_FILE"

#echo "Compiling $INPUT_FILE into $OUTPUT_FILE"
python3 Main.py -f $INPUT_FILE
Loading