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

Parse quote characters #13

Merged
merged 11 commits into from
Nov 18, 2021
Merged

Parse quote characters #13

merged 11 commits into from
Nov 18, 2021

Conversation

Yirmandias
Copy link
Member

@Yirmandias Yirmandias commented Jul 29, 2021

  • Modification of the parse function to support quote, quasiquote and unquote characters.
  • Modification of enum Token:
enum Token {
    Sym { start: usize, end: usize, start_pos: Pos },
    LParen(Pos),
    RParen(Pos),
    //new fields
    Quote(Pos),
    QuasiQuote(Pos),
    Unquote(Pos),
}
  • Modification of the function tokenize to support new kind of Token.
  • Modification of read to transform new tokens into corresponding symbols and construct and SList containing the quote expression.

@arbimo
Copy link
Member

arbimo commented Jul 30, 2021

Clippy errors are likely due to the release of Rust 1.54 that has new clippy rules automatically picked up by CI. I have addressed them in master and you can simply rebase.

planning/src/parsing/sexpr.rs Outdated Show resolved Hide resolved
Ok(SExpr::List(SList {
list: es,
source: src.clone(),
span: Span::new(*start, *start), //TODO: find a way to declare the span
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to fix this and the the tests for contextual display.
My intuition is that the span should finish at the end of e

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function to get the end of e returns a Loc object.

e.loc().end() -> Loc.

From this Loc we cannot get the end Pos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially, you need e.span.end.
span is private is this case but you can add an accessor for the start and end Pos of a Loc

planning/src/parsing/sexpr.rs Outdated Show resolved Hide resolved
Copy link
Member

@arbimo arbimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. There are just 3 minors changes I commented on.

At this point it might be good to split the Atom between a String, a symbol and a number. This could be done in another PR however.

planning/src/parsing/sexpr.rs Outdated Show resolved Hide resolved
planning/src/parsing/sexpr.rs Show resolved Hide resolved
planning/src/parsing/sexpr.rs Outdated Show resolved Hide resolved
@arbimo arbimo merged commit b8ef37c into plaans:master Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants