-
Notifications
You must be signed in to change notification settings - Fork 42
Implementação do parser, criado arquivo README com a explicação da im… #6
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ótimo trabalho! deixei alguns comentários e uma pergunta. a CI está falhando porque falta rodar cargo fmt
para aplicar a formatação padrão
README
Outdated
@@ -0,0 +1,203 @@ | |||
# R-Python: Um Interpretador Python em Rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este README esta bom em principio. No entanto, se formos ser detalhados assim, vai ser complicado manter ela sincronizada conforme a implementação avançar. Talvez valha mais a pena sermos mais alto nível aqui, e considerarmos documentação propriamente como sugerida por Rust: usando ///
.
|
||
#[derive(Debug, Clone)] | ||
pub enum Statement { | ||
VarDeclaration(Box<Name>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugestão: incorporar #5. Name
é alias para String
, que já é tipo de dado com tamanho variável alocado na heap, não precisando estar wrapped por uma Box
.
src/main.rs
Outdated
y = 1 | ||
else: | ||
y = 2"#; | ||
run_test("Basic if-else", test1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acredito que devemos mover todos estes testes para fora da main.
src/parser/parser.rs
Outdated
assert_eq!(rest, ""); | ||
match stmt { | ||
Statement::Assignment(name, expr) => { | ||
assert_eq!(&**name, "x"); // Compare &str with &str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
não baixei o branch para checar, mas acho que assert_eq!(name.as_str(), "x");
atinge o mesmo objetivo com uma sintaxe mais amigável. Pode confirmar por favor?
src/parser/parser.rs
Outdated
assert_eq!(rest, ""); | ||
assert_eq!(stmts.len(), 2); | ||
} | ||
} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excelentes testes
obrigado pelo feedback! estou gostando de trabalhar nessa implementação. Você me recomendaria rodar o sobre o 'assert_eq!(name.as_str(), "x");' dei uma olhada e parece que é sim mais claro com uma sintaxe melhor, não me atentei a isso, mas os dois atingem o mesmo objetivo, como você comentou. |
sim, outro commit seria legal, garantindo que a CI vai ficar verde e com a mudança na sintaxe dos asserts |
Rodei o cargo fmt, creio que agora funcione. |
now tests are fixed and integrated
Parser merge with updated main
…plementação.