{"id":22771487,"url":"https://github.com/pawel-parma/lox-java","last_synced_at":"2025-03-30T12:14:27.159Z","repository":{"id":241078162,"uuid":"803926420","full_name":"Pawel-Parma/lox-java","owner":"Pawel-Parma","description":"Lox implementation \"following\" the book: Crafting Interpreters ","archived":false,"fork":false,"pushed_at":"2024-06-16T19:29:01.000Z","size":126,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T13:51:23.566Z","etag":null,"topics":["crafting-interpreters","craftinginterpreters","jlox","lox","lox-interpreter","lox-language","lox-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pawel-Parma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-21T16:12:53.000Z","updated_at":"2024-06-16T19:29:03.000Z","dependencies_parsed_at":"2024-06-15T13:27:55.898Z","dependency_job_id":"5577cbca-c59f-4e5f-8281-93c967df9438","html_url":"https://github.com/Pawel-Parma/lox-java","commit_stats":null,"previous_names":["pawel-parma/lox-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pawel-Parma%2Flox-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pawel-Parma%2Flox-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pawel-Parma%2Flox-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pawel-Parma%2Flox-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pawel-Parma","download_url":"https://codeload.github.com/Pawel-Parma/lox-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314148,"owners_count":20757463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crafting-interpreters","craftinginterpreters","jlox","lox","lox-interpreter","lox-language","lox-programming-language"],"created_at":"2024-12-11T16:13:57.624Z","updated_at":"2025-03-30T12:14:27.133Z","avatar_url":"https://github.com/Pawel-Parma.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jlox\n\nLox interpreter written in Java following the book [Crafting Interpreters](http://www.craftinginterpreters.com/).\n\n## Branches:\n- ### [*main*](https://github.com/Pawel-Parma/lox-java)\n\nIf you are in the main branch you are looking at the implementation derived from the book.  \nIt has some solved challenges and my own modifications.\n\n\u003cdetails\u003e\n \u003csummary\u003eChanges:\u003c/summary\u003e\n  \u003cul\u003e\n   \u003cli\u003e\n    const - declaration for immutable data. Examples:\n    \u003cbr\u003e\n\n    // Values\n    const x = 1;\n    x = 2; // Error at 'x': Cannot reassign a constant.\n    \n    // Classes\n    class A {\n        init(b) { this.b = 1; }\n    }\n\n    const a = A(1);\n    a.b = 2; // Error at 'b': Cannot modify a field of a constant object.\n    \n    // But this is allowed:\n    var a_mut = a;\n    a.b = 2; // No error\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    break - statement for breaking out of loops. Example:\n    \n    for (var i = 0; i \u003c 10; i = i + 1) {\n        if (i == 5) break;\n        print i;\n    }\n\n    Output:\n    // 0\n    // 1\n    // 2\n    // 3\n    // 4\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    continue - statement for skipping the rest of the loop body. Example: \n    \n    for (var i = 0; i \u003c 10; i = i + 1) {\n        if (i % 2 == 0) continue;\n        print i;\n    }\n\n    Output:\n    // 1\n    // 3\n    // 5\n    // 7\n    // 9\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    Escape sequences in strings - [ \\n, \\r, \\t, \\b, \\', \\\", \\\\ ]. Note \" ' \" still works, no need for \" \\' \".\n    Examples:    \n    \n    // New line\n    print \"Hello\\nWorld\"; // Hello\n                          // World\n                          // \n    \n    // Tab\n    print \"Hello\\tWorld\"; // World  World\n\n    // Backspace\n    print \"Hello\\b World\"; // Hell World\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    String and number concatenation using the '+' operator.\n\n    // string + number\n    print \"123\" + 4; // 1234 (string)\n\n    // number + string\n    print 4 + \"123\"; // 4123 (string)\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    def keyword before method declaration is now required.\n\n    // Before\n    class A {\n        init() { print \"A\"; }\n    }\n\n    // Now\n    class A {\n        def init() { print \"A\"; }\n    }\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    lambda expressions - anonymous functions. Examples:\n\n    // Single line\n    const add = lambda(a, b) { return a + b; };\n    print add(1, 2); // 3\n\n    // Multi line\n    const add = lambda(a, b) {\n        var c = a + b;\n        return c;\n    };\n    print add(3, 2); // 3\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    imports - importing other files. Examples:\n\n    // file1.lox\n    import \"file2\";  // Hello from file2\n    import \"file3\" as math;    \n\n    fun foo() {\n        print \"Hello from foo of file1\";\n    }\n    \n    foo();  // Hello from foo of file1\n    file2.foo();  // Hello from foo of file2\n\n    print math.pow(2, -math.PI);  // 0.0625\n\n    // file2.lox\n    fun foo() {\n        print \"Hello from foo of file2\";\n    }\n\n    print \"Hello from file2\";\n\n    // file3.lox\n    fun pow(val, exp) {\n        if (exp \u003c 0) {\n            return 1 / pow(val, -exp);\n        }\n        var result = 1;\n        for (var i = 0; i \u003c exp; i = i + 1) {\n            result = result * val;\n        }\n        return result;\n    }\n\n    const PI = 3.14;\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\n  \u003cul\u003e\n   \u003cli\u003e\n    modulo operator. Examples:\n\n    print 4 % 2; // 0\n    print 5 % 2; // 1\n\n   \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/details\u003e\n\n- ### [*jlox*](https://github.com/Pawel-Parma/lox-java/tree/jlox)\n\nIf you are in the jlox branch you are looking at the implementation following the book.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawel-parma%2Flox-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpawel-parma%2Flox-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawel-parma%2Flox-java/lists"}