josephzidell / joelang Goto Github PK
View Code? Open in Web Editor NEWA programming language focused on easy reading
A programming language focused on easy reading
Replace the number
primitive type with this set of bit- and sign- specific variants:
To begin, build an AST for a small code sample:
let x = 1;
❯ 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?
// ...
and /* ... */
let
s, const
s, and methods are camelCase; classes are PascalCase[_a-zA-Z][_a-zA-Z0-9]*\??
?
must be boolean[_a-zA-Z][_a-zA-Z0-9]*\??!?
?
must return boolean!
it can throw an error (? comes before !)( ... )
{ ... }
if condition
if
s, for
s, switch
es don't need parens for args, must have braces, except for if
after statementif condition { foo }
or foo if condition
(in latter case, braces aren't allowed)c ? b1 : b2
or c ?: b2
!
a <=> b
(numbers are simple, strings are by char, tuples/arrays are not allowed) return -1, 0, or 1(a, b) -> ...
.
nextcase
to fall through, multiple cases together[...] + [...]
returns new array. Same for tuple <...> + <...>
Build a lexer
Add support for simple enum
s with the general syntax being
enum Foo {
Item1,
Item2,
}
enum Bar extends Foo {
Item3,
}
There are a few structures that need to be lexed and parsed:
nil
if
else
else if
for
loop
return
when
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.
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.
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.
❯ cd ../..
❯ joec
No filename or input provided.
❯ 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.
❯ 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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.