Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fcded3e
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 27, 2025
a817008
add online IDE url; add deadline
github-classroom[bot] Mar 27, 2025
eeb915d
docs: add team member names
Mar 31, 2025
5898b70
analisador lexico (init)
henriporto Apr 8, 2025
24b4700
feat: add comment regex to jflex
Apr 9, 2025
7a66441
newlines, indent e dedent
marcosousa-uff Apr 9, 2025
4f72fb1
Merge pull request #2 from compilers-uff/feat/comment
elihofni Apr 9, 2025
b693d17
fix: cup
Apr 9, 2025
c0fa966
Merge pull request #3 from compilers-uff/fix/cup
elihofni Apr 9, 2025
5ccebd6
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 9, 2025
8e05865
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 9, 2025
94bb519
Create GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 9, 2025
55a4583
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 9, 2025
5201d3b
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
cf5872a
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
6d127a0
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
6133caa
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
1d75300
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
b221671
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
a2d6586
GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
a0ed590
Create GitHub Classroom Autograding Workflow
github-classroom[bot] Apr 13, 2025
b0d13bd
fix LINE_START
marcosousa-uff Apr 16, 2025
3f5725b
correção comentários
henriporto Apr 16, 2025
5d050ef
Merge branch 'compilers-uff:master' into fix-LINE_START
marcosousa-uff Apr 16, 2025
20a7db4
Merge pull request #4 from compilers-uff/fix-LINE_START
marcosousa-uff Apr 16, 2025
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
16 changes: 8 additions & 8 deletions .github/workflows/classroom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lexer e parser
id: lexer-e-parser
- name: expr
id: expr
uses: classroom-resources/autograding-command-grader@v1
with:
test-name: Lexer e parser
setup-command: ''
test-name: expr
setup-command: mvn package
command: java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy
--pass=s --test --dir src/test/data/pa1/sample/
--pass=s --test --dir src/test/data/pa1/sample/expr_plus.py
timeout: 10
max-score: 10
max-score: 1
- name: Autograding Reporter
uses: classroom-resources/autograding-grading-reporter@v1
env:
LEXER-E-PARSER_RESULTS: "${{steps.lexer-e-parser.outputs.result}}"
EXPR_RESULTS: "${{steps.expr.outputs.result}}"
with:
runners: lexer-e-parser
runners: expr
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/4nHL7_6-)
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-2e0aaae1b6195c2367325f4f02e2d04e9abb55f0b24a779b69b11b9e10269abc.svg)](https://classroom.github.com/online_ide?assignment_repo_id=18897626&assignment_repo_type=AssignmentRepo)
# CS 164: Programming Assignment 1

[PA1 Specification]: https://drive.google.com/open?id=1oYcJ5iv7Wt8oZNS1bEfswAklbMxDtwqB
Expand Down Expand Up @@ -31,7 +33,7 @@ See the [PA1 specification][] on the course
website for a detailed specification of the assignment.

Refer to the [ChocoPy Specification][] on the CS164 web site
for the specification of the ChocoPy language.
for the specification of the ChocoPy language.

## Receiving updates to this repository

Expand All @@ -46,8 +48,10 @@ To sync with updates upstream:

## Submission writeup

Team member 1:
Team member 1: Elihofni Guirra Lima

Team member 2:
Team member 2: Henrique de Morais Porto

Team member 3: Marco de Sousa Melo

(Students should edit this section with their write-up)
100 changes: 95 additions & 5 deletions src/main/cup/chocopy/pa1/ChocoPy.cup
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ action code {:
return new ComplexSymbolFactory.Location(first.getLocation()[0],
first.getLocation()[1]);
}
/** Return the rightmost non-whitespace location in NODES, or null if NODES
* is empty. Assumes that the nodes of NODES are ordered left to right. */
ComplexSymbolFactory.Location getRight(List<? extends Node> nodes) {
if (nodes.isEmpty()) {
return null;
}
Node last = nodes.get(nodes.size() - 1);
return new ComplexSymbolFactory.Location(last.getLocation()[0],
last.getLocation()[1]);
}

:}

Expand All @@ -143,11 +153,83 @@ action code {:
* in actions ( {: ... :} ).
*/
terminal NEWLINE;
terminal String PLUS;
terminal Integer NUMBER;

/* Errors */
/* Returned by the lexer for erroneous tokens. Since it does not appear in
* the grammar, it indicates a syntax error. */
terminal UNRECOGNIZED;
terminal UNRECOGNIZED;
terminal INTEGER_OVERFLOW_LEXICAL_ERROR;

/* Keywords. */
terminal String FALSE;
terminal String NONE;
terminal String TRUE;
terminal String AND;
terminal String AS;
terminal String ASSERT;
terminal String ASYNC;
terminal String AWAIT;
terminal String BREAK;
terminal String CLASS;
terminal String CONTINUE;
terminal String DEF;
terminal String DEL;
terminal String ELIF;
terminal String ELSE;
terminal String EXCEPT;
terminal String FINALLY;
terminal String FOR;
terminal String FROM;
terminal String GLOBAL;
terminal String IF;
terminal String IMPORT;
terminal String IN;
terminal String IS;
terminal String LAMBDA;
terminal String NONLOCAL;
terminal String NOT;
terminal String OR;
terminal String PASS;
terminal String RAISE;
terminal String RETURN;
terminal String TRY;
terminal String WHILE;
terminal String WITH;
terminal String YIELD;
terminal String INDENT; // FIXME Validar se está na categoria correta
terminal String DEDENT; // FIXME Validar se está na categoria correta

/* Literals. */
terminal Integer NUMBER;
terminal String IDSTRING;
terminal String STRING;

/* Operators. */
terminal String PLUS;
terminal String MINUS;
terminal String UMINUS;
terminal String STAR;
terminal String DOUBLE_SLASH;
terminal String PERCENT;
terminal String LESS_THAN;
terminal String GREATER_THAN;
terminal String LESS_THAN_EQUAL;
terminal String GREATER_THAN_EQUAL;
terminal String EQUAL_EQUAL;
terminal String NOT_EQUALS;
terminal String ASSIGN;
terminal String LEFT_PAREN;
terminal String RIGHT_PAREN;
terminal String LEFT_BRACKET;
terminal String RIGHT_BRACKET;
terminal String COMMA;
terminal String COLON;
terminal String DOT;
terminal String RIGHT_ARROW;

/* Identifiers. */
terminal String IDENTIFIER;


/* Nonterminal symbols (defined in production rules below).
* As for terminal symbols,
Expand All @@ -162,7 +244,9 @@ non terminal Expr expr, binary_expr;

/* Precedences (lowest to highest) for resolving what would otherwise be
* ambiguities in the form of shift/reduce conflicts.. */
precedence left PLUS;
precedence left PLUS, MINUS;
precedence left STAR;
precedence right UMINUS;

/* The start symbol. */
start with program;
Expand Down Expand Up @@ -205,10 +289,16 @@ expr ::= binary_expr:e {: RESULT = e; :}
| NUMBER:n {: RESULT = new IntegerLiteral(nxleft, nxright, n); :}
;

expr ::= MINUS:op expr:e
{: RESULT = new UnaryExpr(opxleft, exright, op, e); :}
;

/* A binary expression, illustrating how to find the left and right
* source position of a phrase. */
binary_expr ::= expr:e1 PLUS:op expr:e2
{: RESULT = new BinaryExpr(e1xleft, e2xright,
e1, op, e2); :}
;
| expr:e1 MINUS:op expr:e2
{: RESULT = new BinaryExpr(e1xleft, e2xright, e1, op, e2); :}
| expr:e1 STAR:op expr:e2
{: RESULT = new BinaryExpr(e1xleft, e2xright, e1, op, e2); :};
Loading