ziprandom / cltk Goto Github PK
View Code? Open in Web Editor NEWA crystal port of the Ruby Language Toolkit
Home Page: https://ziprandom.github.io/cltk
License: Other
A crystal port of the Ruby Language Toolkit
Home Page: https://ziprandom.github.io/cltk
License: Other
On a very simple file:
require "cltk"
print "hi"
I get this error:
Error in src/cryshlang_tester.cr:2: while requiring "cltk"
require "cltk"
^
in lib/cltk/src/cltk.cr:1: while requiring "./cltk/**"
require "./cltk/**"
^
in lib/cltk/src/cltk/lexers/calculator.cr:35: expanding macro
rule(/[0-9]+/) { |t| {:NUM, t.to_i32}}
^~~~
in lib/cltk/src/cltk/lexers/calculator.cr:35: expanding macro
rule(/[0-9]+/) { |t| {:NUM, t.to_i32}}
^
in macro 'rule' /home/marble/projects/crysh/lib/cltk/src/cltk/scanner.cr:179, line 2:
1.
> 2. rex_rule("[0-9]+", :default) do |t|
3. {:NUM, t.to_i32}
4. end
5.
6.
expanding macro
in macro 'rule' /home/marble/projects/crysh/lib/cltk/src/cltk/scanner.cr:179, line 2:
1.
> 2. rex_rule("[0-9]+", :default) do |t|
3. {:NUM, t.to_i32}
4. end
5.
6.
expanding macro
in macro 'rex_rule' /home/marble/projects/crysh/lib/cltk/src/cltk/scanner.cr:250, line 2:
1.
> 2. @@callbacks.unshift(block_to_proc do |t|
3. {:NUM, t.to_i32}
4. end)
5.
6. @@rx[:default] ||= Array({DFA::DFA::DState, Int32?}).new
7. @@rx[:default].unshift ({ DFA::RegExp.new("[0-9]+").dfa,
8.
9. @@callbacks.size
10.
11. })
12.
expanding macro
in macro 'rex_rule' /home/marble/projects/crysh/lib/cltk/src/cltk/scanner.cr:250, line 2:
1.
> 2. @@callbacks.unshift(block_to_proc do |t|
3. {:NUM, t.to_i32}
4. end)
5.
6. @@rx[:default] ||= Array({DFA::DFA::DState, Int32?}).new
7. @@rx[:default].unshift ({ DFA::RegExp.new("[0-9]+").dfa,
8.
9. @@callbacks.size
10.
11. })
12.
expanding macro
in macro 'block_to_proc' /home/marble/projects/crysh/lib/cltk/src/cltk/scanner.cr:275, line 2:
1.
> 2. ProcType.new do |t, env|
3. env.yield_with_self do
4. {:NUM, t.to_i32}
5. end
6. end
7.
8.
expected block to return (Tuple(Symbol) | Tuple(Symbol, String | Nil) | Nil), not Tuple(Symbol, Int32)
This was on Crystal 0.24.2 BTW
Prior to the crystalize
function being removed, it seemed like that was the intended way to achieve serialization and make CLTK launch faster. I'm currently using CLTK for a shell and it's a significant time loss loading the grammar every time. It takes over a second to load everything for my grammar.
What is the intended way to replace the lost functionality of the crystalize
method?
It would be really handy if you could provide default values for values
listed in an AST node. Something like:
class Def < CLTK::ASTNode
values({
name: String,
visibility: Bool = Visibility::Public
)}
end
or can you already? Sorry, the docs are lacking a little.
f:\programming\source\repos\git\crystal_repos\cltk>crystal spec
Showing last frame. Use --error-trace for full trace.
In lib\crystal-dfa\src\core_ext\range.cr:51:8
51 | struct Tuple(T)
^
Error: type var must be *T, not T
f:\programming\source\repos\git\crystal_repos\cltk
Some patterns give this error:
cast from DFA::AST::LiteralNode to DFA::AST::AlternationNode failed, at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/parser.cr:111:15:111 (TypeCastError)
0x555b67cd0843: consumeLastOrAlternative at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/parser.cr 112:45
0x555b67cceb4c: parse at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/parser.cr 41:13
0x555b67cce5b2: parse at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/parser.cr 12:13
0x555b67cce57f: parse at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/parser.cr 11:5
0x555b67cce52d: initialize at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/regexp.cr 15:11
0x555b67cce501: new at /home/hinrik/src/fjo/lib/crystal-dfa/src/crystal-dfa/regexp.cr 12:5
0x555b67c5963e: __crystal_main at /home/hinrik/src/fjo/bin/test.cr 11:5
0x555b67c693d9: main at /opt/crystal/src/main.cr 12:15
0x7fb5f50612b1: __libc_start_main at ??
0x555b67c5277a: _start at ??
0x0: ??? at ??
Here's a minimal test case:
module CLTK
alias TokenValue = (String|Int32)?
end
require "cltk"
module Fjo
class Lexer < CLTK::Scanner
extend CLTK::Scanner::LexerCompatibility
rule(/(?:a)|b/) { { :FOO } } # works
rule(/b|(?:a)/) { { :BAR } } # doesn't work
end
end
➜ cltk git:(master) ✗ crystal spec
Showing last frame. Use --error-trace for full trace.
In spec/cltk/parser_spec.cr:272:5
272 | @ops : Array(
^---
Error: instance variable '@ops' of RotatingCalc::Environment must be Array(Proc(Int32, Int32, Int32)), not (Array(Proc(Int32, Int32, Float64) | Proc(Int32, Int32, Int32)) | Array(Proc(Int32, Int32, Int32)))
➜ cltk git:(master) ✗
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.