Module: Kapusta
- Defined in:
- lib/kapusta.rb,
lib/kapusta/ast.rb,
lib/kapusta/cli.rb,
lib/kapusta/env.rb,
lib/kapusta/error.rb,
lib/kapusta/errors.rb,
lib/kapusta/reader.rb,
lib/kapusta/support.rb,
lib/kapusta/version.rb,
lib/kapusta/compiler.rb,
lib/kapusta/formatter.rb,
lib/kapusta/compiler/emitter.rb,
lib/kapusta/compiler/normalizer.rb,
lib/kapusta/compiler/macro_expander.rb,
lib/kapusta/compiler/emitter/interop.rb,
lib/kapusta/compiler/emitter/support.rb,
lib/kapusta/compiler/emitter/bindings.rb,
lib/kapusta/compiler/emitter/patterns.rb,
lib/kapusta/compiler/emitter/collections.rb,
lib/kapusta/compiler/emitter/expressions.rb,
lib/kapusta/compiler/emitter/control_flow.rb
Defined Under Namespace
Modules: Compiler, Errors
Classes: AutoGensym, CLI, Comment, Env, Error, Formatter, GeneratedSym, HashLit, List, MacroSym, Quasiquote, Reader, Sym, Unquote, UnquoteSplice, Vec
Constant Summary
collapse
- BlankLine =
Class.new
- VERSION =
'0.5.0'
Class Method Summary
collapse
Class Method Details
.compile(source, path: '(eval)', **_opts) ⇒ Object
26
27
28
|
# File 'lib/kapusta.rb', line 26
def self.compile(source, path: '(eval)', **_opts)
Compiler.compile(source, path:)
end
|
.dofile(path, **_opts) ⇒ Object
20
21
22
23
24
|
# File 'lib/kapusta.rb', line 20
def self.dofile(path, **_opts)
install!
source = File.read(path)
self.eval(source, path:)
end
|
.eval(source, path: '(eval)', **_opts) ⇒ Object
15
16
17
18
|
# File 'lib/kapusta.rb', line 15
def self.eval(source, path: '(eval)', **_opts)
install!
Compiler.run(source, path:)
end
|
.install! ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/kapusta.rb', line 41
def self.install!
return if @installed
@installed = true
Kernel.module_eval do
def require_relative(path)
location = caller_locations(1, 1).first
kap_path = Kapusta.send(:resolve_kap_relative, path, location)
return Kapusta.send(:require_kapusta_file, kap_path) if kap_path
base_file = location&.absolute_path || location&.path
target = base_file ? File.expand_path(path, File.dirname(base_file)) : path
Kernel.require(target)
end
end
end
|
.kebab_to_snake(name) ⇒ Object
4
5
6
|
# File 'lib/kapusta/support.rb', line 4
def self.kebab_to_snake(name)
name.tr('-', '_')
end
|
.require(feature, relative_to: nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/kapusta.rb', line 30
def self.require(feature, relative_to: nil)
install!
feature = feature.to_s
local_path = resolve_require_path(feature, relative_to:)
return require_kapusta_file(local_path) if local_path&.end_with?('.kap')
return Kernel.require(local_path) if local_path
Kernel.require(feature)
end
|