casc-lang / yakou Goto Github PK
View Code? Open in Web Editor NEWAn experimental JVM Language inspired by Rust.
An experimental JVM Language inspired by Rust.
"a" + java::lang::Integer::toString(1)
This will cuase parsing error somehow, require further investigation at toString(
1)
CASC code:
a := 1
b := a as i64
is same as:
int a = 1;
long b = (long) a;
Possible solution: generate a temporary .class
file for ASM to infer (between declaration checking phase and body checking phase)
fn a() {
fn b() {
}
b()
}
Check (Prelude) is used to emit compiled unchecked files into bytecode and load it in current compilation process, this is needed because ClassWriter::getCommonType(String, String)
from ASM lib requires types already exists in JVM environment. But we can override it by checking caching to make sure class exists with our internal type table.
By profiling our compiler, it seems it has some relatively heavy performance penalty from ClassLoader::defineClass(byte[])
. With this proposal, we can reduce lots of time on compilation.
Our typing system needs to be refined so no cached class will be requested to ClassLoader::loadClass(String)
calling and throws exception.
CommonClassWriter::getCommonType
class Human : Animal(), Swimmable {
}
Need to implement & resolve #31 first
public in default.
Java | CASC |
---|---|
public | pub |
protected | prot |
private | priv |
Kotlin | CASC |
---|---|
internal | intl |
Currently we only support primitive types (I'm not sure why there's no System.out.println(S)V), we'll need to support object's print and println.
Possible solution: Checkout dcmpl
and dcmpg
opcodes
use java::util::Arrays as Arr
class Donut
impl Donut {
fn main(args: [str]) {
k := 0
A, B, i, j := 0
z := [f64; 1760]{}
b := [char; 1760]{}
System.out.println("\u001b[2J")
for ;; {
Arr.fill(b, ' ')
Arr.fill(z, 0D)
for mut j := 0D; 6.28 > j; j = j + 0.07 {
for mut i := 0D; 6.28 > i; i = i + 0.02 {
c, e, f, h, D, l, m, n, t :=
Math.sin(i),
Math.cos(j),
Math.sin(A),
Math.sin(j),
Math.cos(A),
d + 2,
1 / (c * h * e + f * g + 5),
Math.cos(i),
Math.cos(B),
Math.sin(B),
c * h * g - f * e
}
}
}
}
}
self
keyword in parameter list like rust
does:impl Main {
pub fn hello(self, s: str[]) {
//...
}
}
self
in parameter list:impl Main {
pub fn hello(s: str[]) {
//...
}
}
impl
block like Java's static blockimpl Main {
comp {
System.out.println("Hello");
}
}
The above example does the same thing as the following Java code:
class Main {
static {
System.out.println("Hello");
}
}
By doing this, we can remove explicit type()
calling while cached file is not loaded by JVM
Reason:
Although ANTLR can greatly provides huge development assistance on lex-parse units, but there are still some big cons come along with: Proper error message is hard to implement, Heavily depends on ANTLR library (not very fine since might encounters some unknown library-internal bugs, thus causes compiler errors even syntax is fine). Therefore, we are going to revamp lex-parse unit manually.
Reason:
Currently, few parts of entire compiler has either TODO or comment, which is not very developer friendly when others want to either contribute CASC compiler unit or take it as an education source, plus there's tons of improper OOP design, which could end up with even creator himself (which is me lol) doesn't actually know how it works.
You can track this issue's progress in branch Revamp. Before this issue being resolved, all other issue are temporarily not in progress.
Note: This Issue's finish date is TBA, and there'll be some minor syntax changes as well.
Current array syntax will conflict with identifier call in BNF grammar, to avoid this, we will introduce Rust's solution:
a := [i32; 3] // array declaration
b := [; 3]{ 1, 2, 3 } // array initialization (no type)
c := [i32; 3]{ 1, 2, 3 } // array initialization
d := [[i32; 3]; 3] // multidimensional array declaration
// and so on
This syntax will greatly makes lots of works easier.
Additionally, we might change array type's syntax (Not final syntax):
i32[]
// into:
[i32]
The following code should throw : "Duplicated field declarations is not allowed."
priv mut:
a: i32
priv mut:
b: i32
Both array initiation and index operator.
intArrayOf()
There are several problem may occurs unexpected issue, need to implement a proper diagnostic system in order to terminate entire compilation as long as there are something went wrong.
This should not happen ;)
You should add multiple assignment syntax for no reason
It's a cool feature in Lua which makes variadic function and multiple return possible
a, b = 1, 2
Reference:
https://www.lua.org/pil/4.1.html
File: example/Donut.casc
This happens when the if expression in line 37
has &&
or ||
operators involved in condition expression.
infinite loop:
for {
//...
}
detailed loop:
for (i := 1; i < 10; i++) {
//...
}
predicate loop:
for i < 10 {
//...
}
CASC doesn't allow declaring array without top dimension size provided:
// err
a := [i32;]{}
b := [[i32;];]{}
// ok
c := [i32;10]{}
d := [[i32;];10]{}
byte -> i8
short -> i16
int -> i32
long -> i64
etc.
This issue is part of refactoring task
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.