Giter VIP home page Giter VIP logo

Comments (20)

misalcedo avatar misalcedo commented on August 30, 2024

Remove end column from location

Use location in scanner

Create helper function to take a token iterator and locations that returns a new location and consumes comments and new lines

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Need to remove graphemes.
The language does not rely on graphemes, only on single code point characters. So we can ignore the grapheme complexity and instead rely on chars iterator and matching against character slices with byte offsets.

Also, simplify number to be an f64 until we implement a more accurate system as a Rust library that compiles to WASM.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Create an error token kind that holds an inner lexical error kind.
Then, the parser can treat invalid tokens as errors to be reported.
The parser would be responsible for reporting errors

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Also check how the book handles lexical errors in the scanner.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Since lexical errors are just errors in parsing a lexeme into a grammar rule, we can have the parser handle both lexical and syntactic errors so that the scanner becomes an infallible iterator of tokens.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Other option is to make Token an enum instead of wrapping it in a result. This would allow the parser to check for kind even on error tokens since we know which token we expected to parse and how much of the lexeme we scanned. This seems like the best option.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Last option is to add an optional lexical error to the tokens. That way tokens are a single type and either have some error or are valid tokens. This is slightly better than the enum as both types would have the same data

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Gonna switch the lexical errors to lexical validations to allow for more than one on a given token. Need to update syntax errors to be called parser errors and to have a syntax error kind (unexpected token kind is a syntax error). Also, update the lexical error to be take a location, list of validation errors, and a lexeme in validate.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Next step is to create TokenKinds type for error display. Also, to implement parsing of other expression types.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Need to implement the "more than one" state of each of the repeating grammar rules. Currently, I only handle missing and one.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Need to fix the grammar rules for numbers. Currently, the parser treats the example as:

(- (+ (- (* 25 3) ((+ 1.75 0.25))) -6.375) 6.375)

I would expect to instead get:

(+ (- (* 25 3) ((+ 1.75 0.25))) -6.375) followed by a singular -6.375 since they are in new lines. However, this may just be a byproduct of not having an expression terminator. From the gramma's perspective. This is correct.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Now implementing a syntax tree interpreter.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Need to fix comparisons and scanning of text references.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Created interpreter following the crafting interpreters book (up to and including chapter 6)

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Next step is improving the interpreter command with navigation, history, and line numbers.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

implemented line numbers

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Investigate why the following fails, but positive works:

2> -011.01#2
-2.75
3> 011.01#2
3.75

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Fixed negative value interrpretation. order of precedence messed it up.

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

also want shift+enter to add a new line instead of reading input

from tortuga.

misalcedo avatar misalcedo commented on August 30, 2024

Done with the editor in the prompt

from tortuga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.