Git Product home page Git Product logo

joelang's People

Contributors

dependabot[bot] avatar josephzidell avatar person-93 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

person-93

joelang's Issues

Build AST

To begin, build an AST for a small code sample:

let x = 1;

Prettier fails a whole bunch of files

❯ npm run prettier

> [email protected] prettier
> prettier --check .

Checking formatting...
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] .github/dependabot.yml
[warn] Ignored unknown option { editorConfig: true }.
[warn] .github/workflows/release.yml
[warn] Ignored unknown option { editorConfig: true }.
[warn] .github/workflows/test-e2e.yml
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] CHANGELOG.md
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] examples/hello-world/.build/main.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] package.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] README.md
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] src/shared/numbers/sizes.ts
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/.build/comparison.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/.build/error.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/.build/maybe.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/.build/range.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/.build/result.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] stdlib/primitives/.build/dec32.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] Ignored unknown option { editorConfig: true }.
[warn] test/hello_world/.build/main.ast.json
[warn] Ignored unknown option { editorConfig: true }.
[warn] tsconfig.json
[warn] Code style issues found in 16 files. Forgot to run Prettier?

Braindump

  • Comments // ... and /* ... */
  • keywords and tokens are case sensitive
  • should tokens use UTF-8?
  • std practice: lets, consts, and methods are camelCase; classes are PascalCase
  • variable regex: [_a-zA-Z][_a-zA-Z0-9]*\??
  • if var ends with ? must be boolean
  • methodName regex: [_a-zA-Z][_a-zA-Z0-9]*\??!?
  • if methodName ends with ? must return boolean
  • if methodName ends with ! it can throw an error (? comes before !)
  • semicolons not needed
  • grouping expressions ( ... )
  • code block { ... }
  • decide how equality checks will happen (==, !=, ===, !==, ~=, ~==)
  • cannot have assignment in if condition
  • ifs, fors, switches don't need parens for args, must have braces, except for if after statement
  • if can be used in 2 ways: if condition { foo } or foo if condition (in latter case, braces aren't allowed)
  • if/then/else/elseif
  • c ? b1 : b2 or c ?: b2
  • for i = 0, i < 10, i++ { ... }
  • for
  • multiple return
  • try/catch
  • not !
  • comparison a <=> b (numbers are simple, strings are by char, tuples/arrays are not allowed) return -1, 0, or 1
  • method call foo()
  • args order: required, with default, variardic (must be array)
  • closure (a, b) -> ...
  • generics
  • hierarchy .
  • && ||
  • switch cases break auto, use nextcase to fall through, multiple cases together
  • enum
  • :symbols see https://elixir-lang.org/getting-started/basic-types.html#atoms
  • figure out strings over multiple lines
  • how to combine arrays [...] + [...] returns new array. Same for tuple <...> + <...>
  • concat strings 'a' + 'b' returns new string
  • import
  • regex
  • hex 0xabc / oct 0o777
  • classes, abstract, extends (can extend multiple and implement multiple - FCFS in case of same method names)

Enum support

Add support for simple enums with the general syntax being

enum Foo {
    Item1,
    Item2,
}

enum Bar extends Foo {
    Item3,
}

Finish last few structures in lexer and parser

There are a few structures that need to be lexed and parsed:

  • Variable declaration with type
  • nil
  • Regex
  • Tuples
  • POJOs
  • member.access
  • if
    • before
      • else
      • else if
    • after
      • after call expression
      • in array
      • in tuple Not supported, use ternary instead
      • in POJO Not supported, use ternary instead
  • ternary
    • in variable declaration
    • in array
    • in tuple
    • in POJO
  • for
  • loop
  • return
    • multiple
    • when
    • ternary
  • classes
  • abstract classes
  • interfaces
  • methods

User Feedback

You asked for some feedback a while ago, not sure if this is what you're looking for or if this is a helpful format for it, if not, let me know and I'll be happy to adjust. This is not really an issue per se, it's just my experience going through it, I am happy to open issues for individual things if that'd be helpful.

Here's a little story, I was kind of bored so it might be a bit hyperbolic and silly but I hope it helps.


The Story

Adventure Begins

I cloned your github repo and the README says the only documentation is on the project website and is not versioned. How do I know if the documentation I am looking at is for the same version of the compiler that I am using? I do not, but I press on.

The Quick Start docs say to add `joelang/.bin` to my path. This does not seem like a good idea to me. Projects that want me to clone their repos to try using them in-tree should not be asking me to do that. I reluctantly add it, but only for the current shell session.

I navigate the the examples directory and go into the hello-world sub-directory. I see that there is a pre-compiled binary there. I find it odd that compiler artifacts are checked into the repo but I try to run it. Unsurprisingly, it does not work.

❯ ./main 
./main: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./main)

It was compiled to use a version of libc not present on my computer.

Compile It

No mind, I can always just recompile it, right?

❯ joec main.joe
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module '/home/person93/projects/josephzidell/joelang/examples/hello-world/_build/compile.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.16.0

This error seems to have nothing to do with the example, so I try again with no input file:

❯ joec
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module '/home/person93/projects/josephzidell/joelang/examples/hello-world/_build/compile.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.16.0

As expected.

You want me to do what? Why?!
It seems I was expected to add `joelang/.bin` to my path despite only being able to run it if my current directory is the project root.
❯ cd ../..

❯ joec
No filename or input provided.
At the Root of It All
❯ joec examples/hello-world/
File examples/hello-world/ does not exist.

❯ joec examples/hello-world/main.joe
Stderr Error: /bin/sh: 1: llc: not found

Stderr Error: /bin/sh: 1: llc: not found

Stderr Error: gcc: error: /home/person93/projects/josephzidell/joelang/examples/hello-world/.build/main.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.

Stderr Error: /home/person93/projects/josephzidell/joelang/examples/hello-world/main: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/person93/projects/josephzidell/joelang/examples/hello-world/main)

Hm.... I definitely have LLVM installed, I use it for other projects... I turn back to the docs.
The requirements are listed after the quick start usage.

This is Required
I find it really odd that I need to have both LLVM and GCC installed, but it should still work because I do.
❯ node -v
v18.16.0

❯ npm -v
9.5.1

❯ llc --version
bash: llc: command not found

❯ gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This is startling to say the least. However, I have a trick up my sleeve.

❯ alias llc=llc-15

❯ llc --version
Debian LLVM version 15.0.7
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: skylake

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    avr        - Atmel AVR Microcontroller
    bpf        - BPF (host endian)
    bpfeb      - BPF (big endian)
    bpfel      - BPF (little endian)
    hexagon    - Hexagon
    lanai      - Lanai
    m68k       - Motorola 68000 family
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc32le    - PowerPC 32 LE
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    sparc      - Sparc
    sparcel    - Sparc LE
    sparcv9    - Sparc V9
    systemz    - SystemZ
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    ve         - VE
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
    xcore      - XCore

❯ joec examples/hello-world/main.joe 
Stderr Error: /bin/sh: 1: llc: not found

Stderr Error: /bin/sh: 1: llc: not found

Stderr Error: gcc: error: /home/person93/projects/josephzidell/joelang/examples/hello-world/.build/main.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.

Stderr Error: /home/person93/projects/josephzidell/joelang/examples/hello-world/main: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/person93/projects/josephzidell/joelang/examples/hello-world/main)

That did not work. Whatever is running llc isn't even using bash. I don't know how it can be convinced to use llc-15 as a valid llc executable.

Conclusion
I am defeated. I will not be able to to compile or run any code written in joelang as things currently stand.

Allow to run `joec` against a dir

If joec is run by passing in a dir, check for a main.joe and compile that just the same if the file had been specified.

All of these should be equivalent.

joec /some/dir/main.joe
joec /some/dir/
joec /some/dir

If no main.joe can be found, display an error.

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.