refactor: formatting
This commit is contained in:
parent
9b75323dc9
commit
23b3ece588
@ -26,7 +26,7 @@
|
|||||||
## v0.0.15
|
## v0.0.15
|
||||||
|
|
||||||
- [x] Multiline comments
|
- [x] Multiline comments
|
||||||
- [ ] Nested multiline comments
|
- [x] Nested multiline comments
|
||||||
- [ ] Include comments in the AST
|
- [ ] Include comments in the AST
|
||||||
- [ ] Replace all panics with actual errors
|
- [ ] Replace all panics with actual errors
|
||||||
- [ ] Remove all old codegen
|
- [ ] Remove all old codegen
|
||||||
|
@ -7,7 +7,7 @@ use super::Transpilable;
|
|||||||
impl Transpilable for PhpAst<'_> {
|
impl Transpilable for PhpAst<'_> {
|
||||||
fn transpile(&self) -> String {
|
fn transpile(&self) -> String {
|
||||||
let mut fragments = vec![String::from("<?php\n")];
|
let mut fragments = vec![String::from("<?php\n")];
|
||||||
|
|
||||||
for statement in self.statements.iter() {
|
for statement in self.statements.iter() {
|
||||||
fragments.push(statement.transpile());
|
fragments.push(statement.transpile());
|
||||||
}
|
}
|
||||||
@ -20,7 +20,8 @@ impl Transpilable for PhpStatement<'_> {
|
|||||||
fn transpile(&self) -> String {
|
fn transpile(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
PhpStatement::PhpEchoStatement(expr_list) => {
|
PhpStatement::PhpEchoStatement(expr_list) => {
|
||||||
let expressions_vec = expr_list.expressions
|
let expressions_vec = expr_list
|
||||||
|
.expressions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|e| e.transpile())
|
.map(|e| e.transpile())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@ -46,5 +47,3 @@ impl Transpilable for PhpExpression<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,18 +56,17 @@ fn multiline_impl(chars: &Vec<char>, start_pos: usize) -> Option<(Vec<char>, usi
|
|||||||
loop {
|
loop {
|
||||||
match chars.get(current_position) {
|
match chars.get(current_position) {
|
||||||
Some('/') => {
|
Some('/') => {
|
||||||
|
|
||||||
match chars.get(current_position + 1) {
|
match chars.get(current_position + 1) {
|
||||||
Some('*') => {
|
Some('*') => {
|
||||||
// Scan nested comment
|
// Scan nested comment
|
||||||
let (mut nested, next_position) = match multiline_impl(chars, current_position + 2)
|
let (mut nested, next_position) =
|
||||||
{
|
match multiline_impl(chars, current_position + 2) {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => {
|
None => {
|
||||||
// The nested comment is not closed.
|
// The nested comment is not closed.
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result.push('/');
|
result.push('/');
|
||||||
result.push('*');
|
result.push('*');
|
||||||
result.append(&mut nested);
|
result.append(&mut nested);
|
||||||
|
@ -110,7 +110,7 @@ mod test {
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => panic!("Expected an error"),
|
Ok(_) => panic!("Expected an error"),
|
||||||
Err(_) => {},
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,10 @@ pub fn parse_token_type(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
lexic::{get_tokens, token::TokenType},
|
lexic::{get_tokens, token::TokenType},
|
||||||
syntax::{parseable::ParsingError, utils::{parse_token_type, Tokenizer}},
|
syntax::{
|
||||||
|
parseable::ParsingError,
|
||||||
|
utils::{parse_token_type, Tokenizer},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::try_operator;
|
use super::try_operator;
|
||||||
@ -133,7 +136,7 @@ mod tests {
|
|||||||
|
|
||||||
match tokens.get_significant(10) {
|
match tokens.get_significant(10) {
|
||||||
Some(_) => panic!("Expected a None"),
|
Some(_) => panic!("Expected a None"),
|
||||||
None => {},
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user