- fixed lexing of inline and postline comments
This commit is contained in:
parent
34573a999e
commit
bcb32b19d4
3 changed files with 18 additions and 12 deletions
14
src/cell.rs
14
src/cell.rs
|
|
@ -59,6 +59,7 @@ pub fn cons (l_ctr: Ctr, r_ctr: Ctr) -> Cell {
|
|||
*/
|
||||
pub fn cell_as_string(c: &Cell, with_parens: bool) -> String {
|
||||
let mut string = String::new();
|
||||
let mut prn_space = true;
|
||||
match &c.car {
|
||||
Ctr::SYMBOL(s) => string.push_str(&s),
|
||||
Ctr::STRING(s) => {
|
||||
|
|
@ -70,10 +71,13 @@ pub fn cell_as_string(c: &Cell, with_parens: bool) -> String {
|
|||
Ctr::FLOAT(f) => string = string + &f.to_string(),
|
||||
Ctr::BOOL(b) => string = string + &b.to_string(),
|
||||
Ctr::CELL(c) => string.push_str(cell_as_string(&c, true).as_str()),
|
||||
Ctr::None => string.push_str("nil")
|
||||
Ctr::None => prn_space = false
|
||||
}
|
||||
|
||||
if prn_space {
|
||||
string.push(' ');
|
||||
}
|
||||
|
||||
string.push(' ');
|
||||
match &c.cdr {
|
||||
Ctr::SYMBOL(s) => string.push_str(&s),
|
||||
Ctr::STRING(s) => {
|
||||
|
|
@ -85,7 +89,11 @@ pub fn cell_as_string(c: &Cell, with_parens: bool) -> String {
|
|||
Ctr::FLOAT(f) => string = string + &f.to_string(),
|
||||
Ctr::BOOL(b) => string = string + &b.to_string(),
|
||||
Ctr::CELL(c) => string.push_str(cell_as_string(&c, false).as_str()),
|
||||
Ctr::None => string.push_str("nil")
|
||||
Ctr::None => {
|
||||
if prn_space {
|
||||
string.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: maybe a better way to do this
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ fn process(document: String) -> Result<Box<Cell>, String> {
|
|||
needs_alloc = true;
|
||||
// reset comment line status
|
||||
if delim == '\n' {
|
||||
delim_stack.pop();
|
||||
ign = false;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue