craftinginterpreters | Repository for the book `` Crafting Interpreters | Interpreter library

 by   munificent HTML Version: Current License: Non-SPDX

kandi X-RAY | craftinginterpreters Summary

kandi X-RAY | craftinginterpreters Summary

craftinginterpreters is a HTML library typically used in Utilities, Interpreter applications. craftinginterpreters has no bugs, it has no vulnerabilities and it has medium support. However craftinginterpreters has a Non-SPDX License. You can download it from GitHub.

This is the repo used for the in-progress book "Crafting Interpreters". It contains the Markdown text of the book, full implementations of both interpreters, as well as the build system to weave the two together into the final site.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              craftinginterpreters has a medium active ecosystem.
              It has 6813 star(s) with 871 fork(s). There are 155 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 77 open issues and 764 have been closed. On average issues are closed in 37 days. There are 28 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of craftinginterpreters is current.

            kandi-Quality Quality

              craftinginterpreters has 0 bugs and 0 code smells.

            kandi-Security Security

              craftinginterpreters has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              craftinginterpreters code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              craftinginterpreters has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              craftinginterpreters releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.
              It has 41723 lines of code, 462 functions and 96 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of craftinginterpreters
            Get all kandi verified functions for this library.

            craftinginterpreters Key Features

            No Key Features are available at this moment for craftinginterpreters.

            craftinginterpreters Examples and Code Snippets

            No Code Snippets are available at this moment for craftinginterpreters.

            Community Discussions

            QUESTION

            Preventing duplicate class error in Java/IntelliJ
            Asked 2022-Mar-09 at 00:58

            I'm writing an interpreter (w. Crafting Interpreters), and I'd like to preserve the working state of the interpreter after each chapter in the same root folder.

            The interpreter's name is jlox, and to preserve its state after chapter 7, I want to duplicate the code in the jlox dir into a jlox[7] dir. See image.

            So, subsequently, I'll duplicate into jlox[Y] dir, where Y = chapter to preserve.

            The problem with copying like this is that IntelliJ sees all the classes as duplicates, preventing any code from building. Is there a way/setting to avoid a duplicate class error with the added constraint of being able to maintain duplicates of the code base in the same folder?

            ...

            ANSWER

            Answered 2022-Mar-09 at 00:58

            I tried a few things and this worked: making every dir under root a module.

            You'll notice in first image (above) that jlox is not a module, but jlox[7] is. So the fix was to make jlox a module as well.

            Source https://stackoverflow.com/questions/71370950

            QUESTION

            Visitor Pattern and Double Dispatch
            Asked 2022-Feb-23 at 19:13

            I know this is well trodden territory but I have a specific question... I promise.

            Having spent very little time in the statically typed, object oriented world, I recently came across this design pattern while reading Crafting Interpreters. While I understand this pattern allows for extensible behavior (methods) on a set of well defined existing types (classes), I don't quite get the characterization of it as a solution to the double dispatch problem, at least not without some additional assumptions. I see it more as making a tradeoff to the expression problem, where you trade closed types for open methods.

            In most of the examples I've seen, you end up with something like this (shamelessly stolen from the awesome Clojure Design Patterns)

            ...

            ANSWER

            Answered 2022-Feb-23 at 19:13

            The comment from @user207421 is spot on. If a language does not natively support double dispatch, no design pattern can alter the language to make it so. A pattern merely provides an alternative which may solve some of the problems that double dispatch would be applied to in another language.

            People learning the Visitor Pattern who already have an understanding of double dispatch may be assisted by explanations such as, "Visitor solves a similar set of problems to those solved by double dispatch". Unfortunately, that explanation is often reduced to, "Visitor implements double dispatch" which is not true.

            The fact you've recognized this means you have a solid understanding of both concepts already.

            Source https://stackoverflow.com/questions/71229342

            QUESTION

            Native Functions meaning?
            Asked 2022-Jan-07 at 00:01

            What "Native functions" means or refers to, in a programming language?

            I am reading the book "Crafting Interpreters" by Robert Nystrom where he has a list on Github with all Lox's implementations that other readers have done in other languages. I saw that one of that list says that it does not have native functions and I would like to know what it means about that?

            https://github.com/munificent/craftinginterpreters/wiki/Lox-Implementations

            ...

            ANSWER

            Answered 2022-Jan-07 at 00:01

            Native Function Definition, from the book "Crafting Interpreters" by Robert Nystrom

            http://craftinginterpreters.com/calls-and-functions.html#native-functions

            Source https://stackoverflow.com/questions/70612408

            QUESTION

            Why the compiler is generating errors which aren't errors at all
            Asked 2021-Dec-22 at 00:47

            I was trying to write my own VM implementation in C++ from the excellent book Crafting Interpreters.

            The book builds a stack based virtual machine, of which I am writing a C++ version

            So here is the code where the compiler is yelling at me.

            object.h

            ...

            ANSWER

            Answered 2021-Dec-22 at 00:47

            You have a cycle in your include files.

            Source https://stackoverflow.com/questions/70438215

            QUESTION

            Mimicking CraftingInterpeter's BINARY_OP macro
            Asked 2021-Oct-18 at 19:39

            Came across this while trying to follow the excellent Crafting Interpreters book but using Rust instead of C.

            The book builds a stack based virtual machine, of which I have a simple Rust version that looks something like:

            ...

            ANSWER

            Answered 2021-Oct-18 at 04:57

            You can pass self as a parameter for your macro:

            Source https://stackoverflow.com/questions/69610395

            QUESTION

            Please, help me to understand parsing trees example from craftinginterpreters.com
            Asked 2021-Apr-02 at 02:20

            I'm trying to build a C compiler from scratch. Googling took me to the https://craftinginterpreters.com/ site. There are a lot of explanations how source code parsers work in detail. I've reached "Parsing expressions" chapter and stuck in this.
            They offer that algorithm of creating parse tree (recursive descend)

            ...

            ANSWER

            Answered 2021-Apr-01 at 19:57

            Let's step through the example expression 1 * 2 - 3. The parser starts at the beginning.

            • The first token matches 1 in primary. Consume 1.
            • Control returns to factor, expr is set to 1. The while condition then matches the *. Consume *.
              • In the while loop, it tries to consume a unary next, this successfully matches primary 2. Consume 2.
              • Expression is set to 1 * 2. No more [*/] to consume, loop terminates. Return this expression to term.
            • term enters while loop and sees -. Consumed - (meaning the next token is 3, not -)
              • Tries to consume a factor, which successfully matches 3 in primary. Consume the 3.
              • Expression is set to 1 * 2 - 3.

            This results in the tree:

            Source https://stackoverflow.com/questions/66909654

            QUESTION

            Error: Conflcting types for xxx pointing to same declaration
            Asked 2021-Jan-15 at 19:35

            I've been writing a tad of C lately. I haven't had too much experience throwing everything into headers, writing their implementations, etc - but I thought I knew enough. At least, until today :P

            Long story short - I'm getting an error of 'conflicting types for ValueArray' - but it points me to the same line for the previous declaration.

            It repeats that for a handful of declarations in that same file, and then declarations in another file as well.

            P.S. The error is not underlined in CLion as well.

            ...

            ANSWER

            Answered 2021-Jan-15 at 19:35

            QUESTION

            Request input regarding code style / best practices
            Asked 2020-Jun-06 at 15:10

            I'm trying to implement a programming language in Common Lisp by following this implementation in Java (https://craftinginterpreters.com/control-flow.html).

            One of the things that was being really bothersome is plenty of slot-values everywhere.

            Granted I can add a line in each function with with-slots, but that's also repetitive, and given that my symbols are not :used but I refer to them by the package, as there is plenty of symbols from many modules and I don't want to lose track from where they come from, even with-slots requires the full qualified name. All this seems to me like very bad code smell.

            I googled and found rutils. With its @object.slot accessor I managed to clean up my code immensely. Just look at the last commit https://github.com/AlbertoEAF/cl-lox/commit/84c0d62bf29bff9a2e0e77042a9108c168542b96?diff=split excerpt:

            (I could paste the code but all of it is available on that repo, I wanted to show the diff highlights)

            Not only it removes some characters, but more importantly, there's one less level of depth (slot-value call) and parenthesis to think about - which helps a lot but for the trivial functions.

            It gets worse when I have lots and lots of symbol names and can no longer export them all because I start having conflicts in symbols.

            Can you guys give me input on the code? This looks much better now but I'm curious as if to are better ways to go about it?

            Thanks!

            ...

            ANSWER

            Answered 2020-Jun-06 at 15:07
            Defining an accessor function in the class definition would also save you some typing while not having to use non-standard syntax

            If you define a CLOS class like this:

            Source https://stackoverflow.com/questions/62185089

            QUESTION

            Common Lisp macro let-curry - not working
            Asked 2020-May-21 at 20:58

            I found myself calling lots of methods whose first argument is a complex object from a given class. Whilst with-slots and with-accessors are useful, generic methods cannot be bound in this way. So I thought: if we could locally curry any functions, slots + accessors + generic functions + functions could all be addressed with the same construct.

            Example of code I want to clean up:

            ...

            ANSWER

            Answered 2020-May-21 at 11:09

            Your version didn't expand to what you wanted but:

            Source https://stackoverflow.com/questions/61923951

            QUESTION

            How do the standard define a C program?
            Asked 2020-Apr-26 at 09:54

            I am studying on how to make a bytecode interpreter (the language i am studing is clox at the site https://craftinginterpreters.com/). In it a valid clox program is defined as a list of declarations. A declaration is defined as either a class, function or variable declaration OR as a statement.

            Now in C, i know there are different kinds of declarations and there are different kinds of statements but none of the types of declarations are a statement and none of the type of statements are a declaration. I think any possible line of C code is either one or the other so how do the standard define a C program ?

            A list of lines that can be either a definition or a statement ?

            ...

            ANSWER

            Answered 2020-Apr-26 at 03:32

            A C program is defined by its grammar and the details of the implementation defined in the standard. Get yourself a copy of the C standard, any version will do for the basics, and look at the grammar. A summary of the grammar can be found in Annex A.

            Section 6.8 defines a statement as being one of any number of specific types of statements.

            Source https://stackoverflow.com/questions/61435354

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install craftinginterpreters

            You can download it from GitHub.

            Support

            One of the absolute best things about writing a book online and putting it out there before it's done is that people like you have been kind enough to give me feedback, point out typos, and find other errors or unclear text. If you'd like to do that, great! You can just file bugs here on the repo, or send a pull request if you're so inclined. If you want to send a pull request, but don't want to get the build system set up to regenerate the HTML too, don't worry about it. I'll do that when I pull it in.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/munificent/craftinginterpreters.git

          • CLI

            gh repo clone munificent/craftinginterpreters

          • sshUrl

            git@github.com:munificent/craftinginterpreters.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Interpreter Libraries

            v8

            by v8

            micropython

            by micropython

            RustPython

            by RustPython

            otto

            by robertkrimen

            sh

            by mvdan

            Try Top Libraries by munificent

            game-programming-patterns

            by munificentHTML

            vigil

            by munificentPython

            mark-sweep

            by munificentC

            magpie

            by munificentPython

            bantam

            by munificentJava