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

Acceptable Parser Version #9

Merged
merged 41 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0872690
feat: brainstorm function call and all its dependants, need test vali…
wilyJ80 Dec 12, 2024
bfc2c52
feat: while and var done
wilyJ80 Dec 13, 2024
797a058
feat: start if: todo: else and endi
wilyJ80 Dec 13, 2024
38d719e
feat: prog - we may or may not be onto something
wilyJ80 Dec 14, 2024
71b8ef2
refactor: prot and param
wilyJ80 Dec 14, 2024
55e2aac
refactor: decl list var
wilyJ80 Dec 14, 2024
84c649a
refactor: decl var
wilyJ80 Dec 14, 2024
bbf8c38
refactor: token match functions
wilyJ80 Dec 14, 2024
e5112d4
refactor: def, now def param
wilyJ80 Dec 14, 2024
f2f2717
refactor: decl list var
wilyJ80 Dec 14, 2024
0a98697
refactor: decl var
wilyJ80 Dec 14, 2024
55d7b3f
refactor: prot
wilyJ80 Dec 14, 2024
b4acca5
fix: empty prot validation
wilyJ80 Dec 14, 2024
b21dc87
fix: prot seems succesfully fixed
wilyJ80 Dec 14, 2024
ac7694d
fix: decl def def loops
wilyJ80 Dec 14, 2024
0c05dcd
fix: decl var bug
wilyJ80 Dec 14, 2024
bd3ed8e
fix: variable declaration
wilyJ80 Dec 14, 2024
9f80bf8
refactor: cmd
wilyJ80 Dec 14, 2024
3621ab5
fix: switch case error for cmd
wilyJ80 Dec 14, 2024
c4f1280
add getout just in case
wilyJ80 Dec 15, 2024
c05c481
refactor: cmd do
wilyJ80 Dec 15, 2024
784f928
finish cmd while
wilyJ80 Dec 15, 2024
e5dbe35
finish var
wilyJ80 Dec 15, 2024
e52273e
finish if proc
wilyJ80 Dec 15, 2024
353d892
refactor: atrib
wilyJ80 Dec 15, 2024
3855a50
update getout
wilyJ80 Dec 15, 2024
bd87023
refactor: expr
wilyJ80 Dec 15, 2024
9fe7ba6
refactor: termo
wilyJ80 Dec 15, 2024
b59d796
refactor: cmd fator
wilyJ80 Dec 15, 2024
800bfba
update fator
wilyJ80 Dec 15, 2024
fb83382
chore: remove warnings
wilyJ80 Dec 15, 2024
f59728a
fix: update fator
wilyJ80 Dec 15, 2024
afc49dd
fix: def param underconsuming
wilyJ80 Dec 15, 2024
1eeb4d8
fix: if
wilyJ80 Dec 15, 2024
f63db49
correct bug
wilyJ80 Dec 15, 2024
ac782c4
fix: bad if
wilyJ80 Dec 15, 2024
5b808c5
fix: while
wilyJ80 Dec 15, 2024
f3c9431
problem: fatrec does not work
wilyJ80 Dec 15, 2024
25ac17d
fix: ref/and problem on lexer
wilyJ80 Dec 15, 2024
42b5988
fix: def param
wilyJ80 Dec 15, 2024
c3b4e34
valid both factorial programs
wilyJ80 Dec 15, 2024
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

# problemas

- [ ] Descartar metodo descendente recursivo? Utilizar metodo de tabela descrevendo as regras de sintaxe?
- [ ] Output colorido em testes
- [ ] Todo ID deve ser checado pelo parser se é reservado?
- [ ] Refactor indispensável no parser: remover erros que não serão usados
Expand Down
4 changes: 2 additions & 2 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
FILE *fd;
int lineCount = 1;

fd = fopen("./doc/examples/code.proc", "r");
fd = fopen("./doc/examples/fatrec.proc", "r");
if (fd == NULL) {
fprintf(stderr, "Error opening file\n");
return EXIT_FAILURE;
Expand Down Expand Up @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
int line = 1;
lc = &line;

fd = fopen("./doc/examples/code.proc", "r");
fd = fopen("./doc/examples/fatrec.proc", "r");
if (fd == NULL) {
fprintf(stderr, "Error opening file\n");
return EXIT_FAILURE;
Expand Down
10 changes: 9 additions & 1 deletion doc/examples/code.proc
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
prot a -
// calcular fatorial recursivo

def fatorial(&int f, int n)
if (n <= 1) f = 1
else
do fatorial(f, n-1)
f = f*n
endi
endp
17 changes: 17 additions & 0 deletions doc/examples/fat.proc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Calcular fatorial iterativo

def init()
int fat = 1, n = 1, z
getint n
if (n <= 1)
fat = 1
else
fat = n
z = n
while (z > 2)
z = z - 1
fat = fat * z
endw
endi
putint fat
endp
16 changes: 16 additions & 0 deletions doc/examples/fatrec.proc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// calcular fatorial recursivo

prot fatorial (&int, int)
def init()
int n, fat
getint n
do fatorial(fat, n)
putint fat
endp
def fatorial(&int f, int n)
if (n <= 1) f = 1
else
do fatorial(f, n-1)
f = f*n
endi
endp
Binary file added doc/modelosint.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion lexer/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct Token lexerGetNextChar(FILE *fd, int *lineCount) {
// State 30: accepting
{},
// State 31
{{32, isRef, SIGN, NOT_OTHER, REF}, {33, isNotRef, SIGN, IS_OTHER, AND}},
{{32, isRef, SIGN, NOT_OTHER, AND}, {33, isNotRef, SIGN, IS_OTHER, REF}},
// State 32: accepting
{},
// State 33: accepting
Expand Down
Loading
Loading