shiika-lang / shiika Goto Github PK
View Code? Open in Web Editor NEWA statically-typed programming language
License: MIT License
A statically-typed programming language
License: MIT License
super
calls the inherited function.
eg.
class A
def self.foo()
foo()
end
end
Does not compile without these lines.
Parse if
like this.
if foo
bar
baz
end
Currently 2 * 2.0
raises error but it is not convenient.
eg.
class A
def initialize
var @a = 1
end
end
A = 1
class B
def foo; A; end
end
Error: Error { msg: "constant `ConstFullname("::A")' was not found", backtrace: stack backtrace:
eg. this does not work
if 1 != 2
puts "ok"
end
With Int#to_s and String#+, we can write this.
size = 600
puts "P4"
puts size.to_s + " " + size.to_s
code_gen/mod.rs is expected to get longer and longer.
Now it is a good time to extract gen_methods into another file.
eg.
class Base
def initialize
@a = 1
end
end
class Sub : Base
def foo -> Int
@a
end
end
Currently it is parse error
Current @main
contains both system code and user program. Extract the latter as a function for better readability of .ll.
foo=
should take only one argument.
Currently the parser supports &&
, ||
but hir and code_gen does not.
cargo run -- run examples/hello.sk
Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
full path not working too.
list files:
hello.sk
hello.sk.ll
hello.sk.opt.ll
At first I'm planning to use Void
as void literal. However I found this conflicts of Void
class object.
How about adding void
pseudo variable like true
and false
?
shiika run ray.sk
fails when IMAGE_WIDTH, IMAGE_HEIGHT is big (like 1000x1000).
https://gist.github.com/yhara/3ac6b67b56a3cf5447a4e641a36ed0b2
Found that this raises error.
class Base
def initialize(i: Int)
@a = i
putd @a #=> "ivar `@a\' was not found"
end
end
It is nice if we could write tests in Shiika, not in Rust.
Current user_main
has constant initialization in addition to "real" user main. Extract them as a llvm func (like init_const
or so)
Currently Lexer
does not distinguish ;
from newline, but there is a case where newline is allowed but semicolon is not.
Example:
# OK
foo(1,
2)
# NG
foo(1,;2)
v 0.2.5 (09b0cf5)
error[E0583]: file not found for module `float`
--> src/corelib/mod.rs:2:1
|
2 | mod float;
| ^^^^^^^^^^
|
= help: to create the module `float`, create file "src/corelib/float.rs"
error[E0583]: file not found for module `int`
--> src/corelib/mod.rs:3:1
|
3 | mod int;
| ^^^^^^^^
|
= help: to create the module `int`, create file "src/corelib/int.rs"
error[E0425]: cannot find function `create_methods` in module `float`
--> src/corelib/mod.rs:44:27
|
44 | ("Float" , float::create_methods() , vec![] , HashMap::new()),
| ^^^^^^^^^^^^^^ not found in `float`
|
help: possible candidates are found in other modules, you can import them into scope
|
11 | use crate::corelib::bool::create_methods;
|
11 | use crate::corelib::never::create_methods;
|
11 | use crate::corelib::object::create_methods;
|
11 | use crate::corelib::shiika_internal_ptr::create_methods;
|
and 2 other candidates
error[E0425]: cannot find function `create_methods` in module `int`
--> src/corelib/mod.rs:45:25
|
45 | ("Int" , int::create_methods() , vec![] , HashMap::new()),
| ^^^^^^^^^^^^^^ not found in `int`
|
help: possible candidates are found in other modules, you can import them into scope
|
11 | use crate::corelib::bool::create_methods;
|
11 | use crate::corelib::never::create_methods;
|
11 | use crate::corelib::object::create_methods;
|
11 | use crate::corelib::shiika_internal_ptr::create_methods;
|
and 2 other candidates
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0425, E0583.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `shiika`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
eg. 3.0 % 2
results in
Error: Error { msg: "method MethodFirstname("%") not found on ClassFullname("Float")", backtrace: 0: backtrace::backtrace::libunwind::trace
eg.
class A; end
class B : A; end
Given this, define #a
, #b
and #b=
automatically
class A
def initialize
@a = 1
var @b = 2
end
end
eg.
class Base
A = 1
end
class Sub : Base
def foo
puts A #=> 1
end
end
eg.
A = 1
A = 2 # should be error
Not that this is legal:
if foo
A = 1
else
A = 2
end
Successor of #84
[1,2]
should be inferred as Array<Int>
[1,2]
Array<Int>.new
should be existArray<T>.new
instead.[1].first
should be inferred as IntGot ParseError with this
x = 0
1 + (x * 2)
Or just:
i = 2
(i * 3)
Long way to go...
Especially, code gen of Float/Int/Bool needs to be reconsidered to support Array<Object>
.
Fix duplicated code of them
Error: Error { msg: "expected separator but got Equal", backtrace: stack backtrace:
eg.
class A
end
A.new #=> should not raise error
Note: Shiika will not support unless-else
(in contrast to Ruby).
Current test passes even when no code is successfully executed.
Should add puts "ok"
or something and check it.
Try compiling 7cf106d
In Ruby, "stdlib" refers classes that loaded by explicit require
and "corelib" means classes do not need require
.
I heard there's a technique to accept both &str and String as an argument. With this we can avoid unneeded .to_string()
s.
So that they can be displayed with {}
in format!
eg.
class A
class B
end
end
b = A::B.new
eg. puts "ok" if x == y
Since #23, the line number in error report includes corelib ๐ญ
42: _main (0x1037c2bc1), details: ParseError { location: Cursor { line: 66, col: 7, pos: 1750 } } }
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.