mamidon / newt

What if we designed a web browser specifically for making desktop GUIs?
1 stars 0 forks source link

Clean up before hello, world GUI #4

Open mamidon opened 4 years ago

mamidon commented 4 years ago

Before I advance on to making a super simple hello world app with web render we have some house cleaning to do first.

  1. Convert the snapshot tokenization tests I disabled to actual unit tests
  2. Double check the tree snapshot tests I deleted to make sure I've not introduced any gaps
  3. Address the parsing precedence problem (chaining function calls to property expressions) by doing pratt parsing, except correctly this time.
  4. Make a pass at reducing the burden of using NewtValue on the native side of things: 4a. Make it easier to instantiate an object, building up a hashmap is a lot of work 4b. Hide the Rc & RefCells 4c. Introduce simple, deep object equality
  5. Make a pass at SyntaxKind, ExprKind, StmtKind, RValKind, TokenKind to make sure they're all copy, debug, and display.
  6. Implement a (lisp (style)) display & debug for SyntaxTrees, SyntaxElement/Node/Token
  7. Ditch the current behavior of the program. Instead by default we take whatever comes through stdin and execute it. You can optionally specify a flag to read in a file. You can optionally specify a flag to go straight to repl (and immediately execute any newt code that's been piped into stdin?). You can optionally ask for output to include tokens or trees via flags too.
  8. And split all these out into their own issues.
mamidon commented 4 years ago

For #3, re-read http://craftinginterpreters.com/compiling-expressions.html#a-pratt-parser !

type ParseFunction = Box<dyn Fn(&mut Parser) -> CompletedMarker>;
enum PrecedenceRuleKind {
    Prefix(ParseFunction),
    Infix(ParseFunction)
}
struct PrecedenceRule {
    precedence: usize,
    token_kind: TokenKind,
    parse_function: PrecedenceRuleKind
}