Skip to content
This repository has been archived by the owner on Feb 14, 2021. It is now read-only.

Primera Entrega #53

Open
wants to merge 156 commits into
base: entrega-final
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
9596904
include ply lexer and parser
krortg Feb 15, 2020
6d92db9
Merge remote-tracking branch 'upstream/entrega-parser'
krortg Feb 15, 2020
e4bf9f9
passing lexer test
krortg Feb 18, 2020
22690bf
including TYPEID in grammar rules
krortg Feb 18, 2020
c2098c0
solving issues in cool.sh and running parser tests
krortg Feb 18, 2020
06559a3
hotfix in grammar
krortg Feb 18, 2020
7c58843
changing grammar for expr operations
krortg Feb 18, 2020
42c6d53
to merge
krortg Feb 18, 2020
ae38b11
Error Token added for Syntax Error report
krortg Feb 18, 2020
f9273b0
Merge remote-tracking branch 'upstream/entrega-parser' into tests
krortg Feb 19, 2020
950292c
adding ply to requirements.txt
krortg Feb 20, 2020
1710a41
adding ply to requirements.txt
krortg Feb 20, 2020
2cc9be0
update readme with names
krortg Feb 21, 2020
94cb3d8
passing lex-parser test with pipeline
krortg Feb 22, 2020
4d0caad
updating pipeline and adding reader for missing input files
krortg Feb 23, 2020
7c647c2
Merge branch 'pipeline'
krortg Feb 23, 2020
259044d
include visitor.py
krortg Feb 23, 2020
58ad062
adding compiler error classes and semantic module
krortg Feb 25, 2020
bc6fb3e
adding error node
krortg Feb 26, 2020
5c3fe55
update copyright
Mar 3, 2020
b9a454d
Merge branch 'entrega-parser' of https://github.com/CRafa97/cool-comp…
Mar 29, 2020
b428265
semantic structure and visitor templates
Mar 29, 2020
c800602
solving import errors and including first format visitor version
May 6, 2020
ab0f10a
update gitignore with code config folder
Jun 3, 2020
4d4bcbe
fixing ast abstract nodes and include first visitors code
Jun 3, 2020
99dc825
working on type builder
Jun 15, 2020
3e07193
testing type-builder visitor
Jun 20, 2020
2e1db00
removing ast.txt file from git
krl97 Jul 16, 2020
55a5bb5
ignoring ast.txt from repo
krl97 Jul 16, 2020
b5017b0
new scope implementation and fixing errors in VCollector and TChecker
krl97 Jul 17, 2020
17acf40
pretty print for scopes
krl97 Jul 18, 2020
6228293
minor changes in semantic phase
krl97 Oct 11, 2020
9e44bce
adding line and col to ast nodes
Oct 31, 2020
e1c491c
getting test response
Nov 3, 2020
42f7599
resolving semantic tests
Nov 5, 2020
2f35fe1
reciving test
Nov 5, 2020
65a7e86
passing new type test
Nov 6, 2020
9b08500
pulling codegen test
Nov 23, 2020
e0202d3
some gitignore changes
Oct 24, 2020
45b55f5
initial skeleton for nodeIL structure
Nov 1, 2020
95b074f
adding some complex nodeIL types
Nov 3, 2020
11a850f
some code adjustment
Nov 3, 2020
78547f3
adding skeleton for transpilator from COOL to IL, and virtualTable he…
Nov 3, 2020
de48b2d
operation nodes definition
Nov 5, 2020
bff5734
assignments node definitions
Nov 5, 2020
4074a86
some allocate IL
Nov 6, 2020
8fa4673
some redefinitions in operation and allocate nodes
Nov 6, 2020
2d59a1f
some definitions in MethodsNodeIL
Nov 6, 2020
2ad5ab4
some other methodsIL definitions
Nov 6, 2020
16339c6
adding transpilator def, virtual table def and variables def
Nov 6, 2020
a67b3f9
variables class completed missing some test
Nov 6, 2020
4a17a51
finishing add method functionality in virtual table
Nov 7, 2020
8ed3e42
starting visitor skeleton for transpilator
Nov 8, 2020
f00c645
adding some other visitor nodes
Nov 8, 2020
ca94dd9
some correction in import and some defs
Nov 8, 2020
a9e7abe
some methods in transpilator, class constructor, built ins constructo…
Nov 10, 2020
d30e126
collect types method completed
Nov 10, 2020
14e0497
binary and unary operations visitor for transpilator
Nov 11, 2020
eaff126
vistor -> expersions: atomics
Nov 11, 2020
da12e01
vistor -> expresions: constants
Nov 11, 2020
7b2baf0
visitor-> block node
Nov 12, 2020
c9d980a
visitor-> while node
Nov 12, 2020
1c0139a
visitor-> conditional node
Nov 12, 2020
46a3020
visitor-> let node
Nov 12, 2020
d879e8d
visitor-> assign node
Nov 12, 2020
d592078
visitor-> case node
Nov 12, 2020
672b505
visitor-> class declaration node
Nov 12, 2020
6426b48
visitor-> func declaration node
Nov 12, 2020
1c7c1ff
visitor-> var declaration node
Nov 12, 2020
6361350
visitor -> self dispatch
Nov 13, 2020
77ea185
visitor -> point dispatch
Nov 13, 2020
1ce6fec
visitor -> parent dispatch
Nov 13, 2020
e108745
visitor for IL to mips skeleton
Nov 13, 2020
273959b
some initials for mips visitor, statics and else
Nov 13, 2020
610a8fe
assignations and other visit methods
Nov 13, 2020
bef067a
PushIL and PopIL
Nov 13, 2020
de90d83
LoadLabelIL
Nov 14, 2020
8e908e2
return IL
Nov 14, 2020
e37a9ae
binary operations IL
Nov 14, 2020
e4079ef
allocate IL method
Nov 14, 2020
adbd831
hierarchy IL
Nov 15, 2020
755ec05
virtual table IL
Nov 15, 2020
86b9699
completing IL visitor, dispatch methods
Nov 15, 2020
b6a723d
some correctios in file distribution, and misstyping in visitors
Nov 15, 2020
8b24613
testing some changes
Nov 24, 2020
ba3cd17
puliendo detalles de generacion
Nov 24, 2020
f29239f
starting to debugg
Nov 24, 2020
28ed81e
seeking errors
oschdez97 Nov 24, 2020
1ef6f96
correcting some bugs in code generation
oschdez97 Nov 24, 2020
3540db5
some bugs corrections in transpilator, missing some tests
oschdez97 Nov 24, 2020
98f3fb0
some other corrections, and virtual table adding missing methods
oschdez97 Nov 24, 2020
802c54d
some corrections, in transpilator for collecting types, virtual_table…
oschdez97 Nov 25, 2020
1405248
some fixxes for HierarchyIL and VirtualTableIL in transpilator, still…
oschdez97 Nov 26, 2020
658b9ab
fixxing some structure mips final code
oschdez97 Nov 26, 2020
a324607
setting initial missing code
oschdez97 Nov 26, 2020
ac15d7c
some reviews in process
oschdez97 Nov 27, 2020
2bb06e7
fixxes in mips output, compiling correctly, still getting errors
oschdez97 Nov 27, 2020
c018eb4
first code gen test passed, still debuggin
oschdez97 Nov 28, 2020
307699a
fixxes for complete tests compilation
oschdez97 Nov 28, 2020
4370228
main.py fixxes for tests PASSING
oschdez97 Nov 28, 2020
3ec1c7e
resolving case node problem
Nov 28, 2020
ce6debf
some corrections in virtual table for inheritance methods display in …
oschdez97 Nov 28, 2020
0993d8a
rge branch 'code_gen' of https://github.com/CRafa97/cool-compiler-202…
oschdez97 Nov 28, 2020
1026775
some bugs corrected in transpilator
oschdez97 Nov 28, 2020
708583a
anoting dynamic types in context
Nov 28, 2020
b540eb5
reciving changes
Nov 28, 2020
3908a28
isvoid expr anoting
Nov 28, 2020
ba8d18b
some changes in logic, for some dispatch
oschdez97 Nov 29, 2020
430dc11
Merge branch 'code_gen' of https://github.com/CRafa97/cool-compiler-2…
oschdez97 Nov 29, 2020
d7e60c0
some fixxes, IO.out_String, push, pop errors
oschdez97 Nov 30, 2020
4fab57a
working on report, adding parsing.md
Nov 30, 2020
bbf4dc5
get more codegen changes
Nov 30, 2020
996be3d
some other corrections $ra
oschdez97 Nov 30, 2020
1d1d8ff
Merge branch 'code_gen' of https://github.com/CRafa97/cool-compiler-2…
oschdez97 Nov 30, 2020
aa3662e
all test compiling correctly, some wrong answers thrown
oschdez97 Nov 30, 2020
8f101e6
report ok
Nov 30, 2020
18a9741
last changes from remote origin
Nov 30, 2020
fb455e1
get changes from upstream/entrega-final
Nov 30, 2020
9837498
working in static methods
Dec 4, 2020
097dd46
different aproach for bug fixxing, attempting bottom-up strategy
Dec 5, 2020
f74fc91
some corrections in returns, functions beginings, and some statics me…
Dec 5, 2020
8935d0c
some bug corrections in $sp use, $fp, and other functionalities
Dec 6, 2020
cf51bd4
substr mips
Dec 6, 2020
90019ef
adding venv
Dec 6, 2020
cabfae1
getting changes
Dec 6, 2020
0d0a8be
IL redefinition to CIL
Dec 9, 2020
e1a062b
IL redef, transpilator rebase, mips rebase, still testing
Dec 11, 2020
199e476
more changes
Dec 11, 2020
8f11fb4
new cil definition
Dec 11, 2020
856a31c
add semantic scope to transpilator
Dec 11, 2020
efe6db2
some transpilator visitor adds, some errors persist
Dec 12, 2020
575177b
some test already working
Dec 13, 2020
09100cc
print-cool and hello_world PASSED
Dec 13, 2020
6a6d31d
some changes in visitor
Dec 13, 2020
38478ab
solving init labels and dynamic exprs
Dec 13, 2020
219d15a
working in gitignore
Dec 13, 2020
14745ce
solving init labels and dynamic exprs
Dec 13, 2020
ca9d79c
working on missiong labels
Dec 13, 2020
1ca9470
fixxing some GotoIF missing, new test PASSED fib, atoi, new-complex, …
Dec 13, 2020
4df8fca
io.cl PASSED, constructors fixxed
Dec 13, 2020
f74be86
fixxing LoadNodeIL
Dec 14, 2020
eed666e
solving scope expr_dict
Dec 14, 2020
df3e889
solving ascope problems
Dec 14, 2020
8005b56
passing hairscary.cl
Dec 14, 2020
501470d
new test passed, BoolConstant misstype, PASSED primes, list
Dec 14, 2020
af49166
some fixxes in type inference for EqualNode, palindrome PASSED, arith…
Dec 14, 2020
a762e32
let declarations fixxed, assign node il, cells PASSED life PASSED
Dec 14, 2020
dd663f8
solving expr index
Dec 14, 2020
4ad38bf
fixxing StarNode bug
Dec 14, 2020
49df9a2
offset for methods vars, fixxed
Dec 14, 2020
ef77e79
fixxing bug in CaseNode
Dec 14, 2020
57c876e
solving graph in context
Dec 15, 2020
c33bc9c
merge incoming changes
Dec 15, 2020
cb00f0c
passing all tests :)
Dec 15, 2020
ea4b403
passing all tests :)
Dec 15, 2020
e581d7b
removing excesive prints, compiler done!
Dec 15, 2020
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Created by https://www.gitignore.io/api/visualstudiocode,linux,latex,python
# Edit at https://www.gitignore.io/?templates=visualstudiocode,linux,latex,python

# VCode Settings
.vscode

### LaTeX ###
## Core latex/pdflatex auxiliary files:
*.aux
Expand Down Expand Up @@ -408,3 +411,7 @@ dmypy.json

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

src/ast.txt
#src/main.py
.idea
#test
45 changes: 19 additions & 26 deletions doc/Readme.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# Documentación

> Introduzca sus datos (de todo el equipo) en la siguiente tabla:
> La siguiente tabla contiene los datos del equipo:

**Nombre** | **Grupo** | **Github**
--|--|--
Nombre1 Apellido1 Apellido2 | C4xx | [@github_user](https://github.com/<user>)
Nombre2 Apellido1 Apellido2 | C4xx | [@github_user](https://github.com/<user>)
Nombre3 Apellido1 Apellido2 | C4xx | [@github_user](https://github.com/<user>)
Oscar Luis Hernandez Solano | C411 | [@oschdez97](https://github.com/oschdez97)
Harold Rosales Hernandez | C411 | [@hros18](https://github.com/hros18)
Carlos Rafael Ortega Lezcano | C411 | [@CRafa97](https://github.com/CRafa97)

## Readme
> El informe escrito del compilador se encuentra en la carpeta `report` de este directorio

Modifique el contenido de este documento para documentar de forma clara y concisa los siguientes aspectos:
## Uso del Compilador

- Cómo ejecutar (y compilar si es necesario) su compilador.
- Requisitos adicionales, dependencias, configuración, etc.
- Opciones adicionales que tenga su compilador.
Para instalar todas las dependencias del compilador ejecute desde el directorio raiz del proyecto

### Sobre los Equipos de Desarrollo
```bash
pip install -r requirements.txt
```

Para desarrollar el compilador del lenguaje COOL se trabajará en equipos de 2 o 3 integrantes. El proyecto de Compilación será recogido y evaluado únicamente a través de Github. Es imprescindible tener una cuenta de Github para cada participante, y que su proyecto esté correctamente hosteado en esta plataforma. Próximamente les daremos las instrucciones mínimas necesarias para ello.
Para ejecutar el compilador debe moverse al directorio ```src```, y ejecutar el archivo ```cool.sh``` dando como entrada la direccion del archivo a compilar

### Sobre los Materiales a Entregar
```bash
cd src/
./cool.sh '../tests/codegen/hello_world.cl'
```

Para la evaluación del proyecto Ud. debe entregar un informe en formato PDF (`report.pdf`) que resuma de manera organizada y comprensible la arquitectura e implementación de su compilador.
El documento **NO** debe exceder las 5 cuartillas.
En él explicará en más detalle su solución a los problemas que, durante la implementación de cada una de las fases del proceso de compilación, hayan requerido de Ud. especial atención.
En caso que no tenga `bash` puede ejecutar directamente el script `main.py` que contiene el proceso de compilacion mediante el pipeline

### Estructura del reporte

Usted es libre de estructurar su reporte escrito como más conveniente le parezca. A continuación le sugerimos algunas secciones que no deberían faltar, aunque puede mezclar, renombrar y organizarlas de la manera que mejor le parezca:

- **Uso del compilador**: detalles sobre las opciones de líneas de comando, si tiene opciones adicionales (e.j., `--ast` genera un AST en JSON, etc.). Básicamente lo mismo que pondrá en este Readme.
- **Arquitectura del compilador**: una explicación general de la arquitectura, en cuántos módulos se divide el proyecto, cuantas fases tiene, qué tipo de gramática se utiliza, y en general, como se organiza el proyecto. Una buena imagen siempre ayuda.
- **Problemas técnicos**: detalles sobre cualquier problema teórico o técnico interesante que haya necesitado resolver de forma particular.

## Sobre la Fecha de Entrega

Se realizarán recogidas parciales del proyecto a lo largo del curso. En el Canal de Telegram [@matcom_cmp](https://t.me/matcom_cmp) se anunciará la fecha y requisitos de cada primera entrega.
```bash
python3 main.py '../tests/codegen/hello_world.cl'
```
178 changes: 178 additions & 0 deletions doc/parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Parsing

## Cool Tokens

'CLASS',
'INHERITS',
'IF',
'THEN',
'ELSE',
'FI',
'WHILE',
'LOOP',
'POOL',
'LET',
'IN',
'CASE',
'OF',
'ESAC',
'NEW',
'ISVOID',
'NOT',

'INTEGER', # int
'STRING', # string
'BOOL', # bool
'PLUS', # +
'MINUS', # -
'STAR', # *
'DIVIDE', # /
'BITNOT', # ~
'LESS', # <
'LESSQ', # <=
'EQUALS', # =
'WITH', # =>
'ASSIGN', # <-
'LPAREN', # (
'RPAREN', # )
'LBRACE', # {
'RBRACE', # }
'SEMI', # ;
'COLON', # :
'COMMA', # ,
'DOT', # .
'ARROBA', # @
'TYPEID',
'ID',
'ERROR'

## Cool Grammar

program : class_list

class_list : def_class
| def_class class_list

def_class : CLASS TYPEID LBRACE feature_list RBRACE SEMI
| CLASS TYPEID INHERITS TYPEID LBRACE feature_list RBRACE SEMI

feature_list : def_attr SEMI feature_list
| def_func SEMI feature_list
| empty

def_attr : ID COLON TYPEID
| ID COLON TYPEID ASSIGN expr

def_func : ID LPAREN param_list RPAREN COLON TYPEID LBRACE expr RBRACE

param_list : param_build
| empty

param_build : param empty
| param COMMA param_build

param : ID COLON TYPEID

expr : LET let_list IN expr
| CASE expr OF cases_list ESAC
| IF expr THEN expr ELSE expr FI
| WHILE expr LOOP expr POOL
| ID ASSIGN expr
| arith
| expr PLUS expr
| expr MINUS expr
| expr STAR expr
| expr DIVIDE expr
| expr LESS expr
| expr LESSQ expr
| expr EQUALS expr
| BITNOT expr
| ISVOID expr
| NOT expr

let_list : let_assign
| let_assign COMMA let_list

let_assign : ID COLON TYPEID ASSIGN expr
| ID COLON TYPEID

cases_list : case SEMI
| case SEMI cases_list

case : ID COLON TYPEID WITH expr

arith : base_call

base_call : fact ARROBA TYPEID DOT ID LPAREN arg_list RPAREN
| fact

fact : fact DOT ID LPAREN arg_list RPAREN
| ID LPAREN arg_list RPAREN
| atom
| LPAREN expr RPAREN

arg_list : arg_build
| empty

arg_build : expr empty
| expr COMMA arg_build

atom : INTEGER
| ID
| NEW TYPEID
| LBRACE block RBRACE
| BOOL
| STRING

block : expr SEMI
| expr SEMI block

## Cool AST

ASTNode
|
├── ProgramNode
├── ClassDeclarationNode
├── AttrDeclarationNode
├── FuncDeclarationNode
├── FormalParamNode
├── VarDeclarationNode
|
├── ExprNode
│ ├── OperationNode
| | ├── BinaryOperationNode
| | | ├── SumNode
| | | ├── DifNode
| | | ├── StarNode
| | | ├── DivNode
| | | ├── LessNode
| | | ├── LessEqualNode
| | | └── EqualNode
| | |
| | └── UnaryOperationNode
| | ├── BitNotNode
| | └── NotNode
| |
│ ├── VariableNode
│ ├── NewNode
│ ├── ConditionalNode
│ ├── LetNode
│ ├── LetDeclarationNode
│ ├── BlockNode
│ ├── CaseNode
│ ├── AssignNode
│ ├── IsVoid
│ ├── ConditionalNode
│ ├── WhileNode
│ |
│ ├── SelfCallNode
│ ├── ParentCallNode
│ ├── ExprCallNode
| |
│ └── ConstantNode
| ├── IntegerNode
| ├── StringNode
| └── BoolNode
|
└── ErrorNode
Binary file added doc/report/report.pdf
Binary file not shown.
Loading