halunke 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d378d2686f483584090e764b7d90eeb13b18614c
4
- data.tar.gz: 7f280aa4dfe247d55b37b863a8766bf9113fb80f
3
+ metadata.gz: 611b6eded86f2cd9eba6b40582ef203160280782
4
+ data.tar.gz: a80ebee17d3997bc197f79739c7ee872a1f94340
5
5
  SHA512:
6
- metadata.gz: 5d1721feb87183a3be4cb3efd2420cb1b4ca5263fcc525413c64ee1884420441761200227f200572a38f24d9b12e1b12f29ccfcafae05d7498cc3179a9a0dd41
7
- data.tar.gz: ae52853223039380e48c35eb867f693a88b257f8510b9d79c67e4e0641d89df3489a3104ebffadc0bcdc5a9edcf588dae68f218e82c36a930f0d5e421bdb1340
6
+ metadata.gz: 737f95c019feaddc4f00971de2f3976271dd27cd037405459de1108547ac14304a66a4996c25ef741ce6a0c9c7ec17f2df0d173cae20ed2f31a03d7ce75fd95d
7
+ data.tar.gz: a92aa49019b18f1dafa0ab784d853ca2184ec694848f8f813875f94b4a09af1ea02b33673acffd88d226b5a6bafb0ae518ce51e9bee7e54a2628ae6a9e9c39f1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- halunke (0.4.0)
4
+ halunke (0.5.0)
5
5
  rack (~> 2.0.4)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -14,7 +14,7 @@ It also has the following characteristics:
14
14
 
15
15
  * There is no null/nil value in the language
16
16
 
17
- Find out more on the [documentation page](https://moonglum.github.io/halunke).
17
+ Find out more on the [documentation page](http://halunke.jetzt).
18
18
 
19
19
  ## License
20
20
 
@@ -0,0 +1 @@
1
+ halunke.jetzt
@@ -7,7 +7,5 @@ title: Halunke!
7
7
  description: >-
8
8
  Halunke is a dynamic, object-oriented language that has a simple grammar inspired by Smalltalk and Lisp
9
9
 
10
- baseurl: "/halunke"
11
-
12
10
  # Build settings
13
11
  markdown: kramdown
@@ -9,48 +9,51 @@
9
9
  </head>
10
10
  <body>
11
11
  <div class="container">
12
- <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
13
- <a class="navbar-brand" href="/halunke">Halunke!</a>
12
+ <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-1">
13
+ <a class="navbar-brand" href="/">Halunke!</a>
14
14
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
15
15
  <span class="navbar-toggler-icon"></span>
16
16
  </button>
17
17
  <div class="collapse navbar-collapse" id="navbarNav">
18
18
  <ul class="navbar-nav">
19
19
  <li class="nav-item">
20
- <a class="nav-link" href="/halunke">Intro</a>
20
+ <a class="nav-link" href="/">Intro</a>
21
21
  </li>
22
22
  <li class="nav-item">
23
- <a class="nav-link" href="/halunke/number">Number</a>
23
+ <a class="nav-link" href="/number">Number</a>
24
24
  </li>
25
25
  <li class="nav-item">
26
- <a class="nav-link" href="/halunke/string">String</a>
26
+ <a class="nav-link" href="/string">String</a>
27
27
  </li>
28
28
  <li class="nav-item">
29
- <a class="nav-link" href="/halunke/array">Array</a>
29
+ <a class="nav-link" href="/array">Array</a>
30
30
  </li>
31
31
  <li class="nav-item">
32
- <a class="nav-link" href="/halunke/dictionary">Dictionary</a>
32
+ <a class="nav-link" href="/dictionary">Dictionary</a>
33
33
  </li>
34
34
  <li class="nav-item">
35
- <a class="nav-link" href="/halunke/true-false">True & False</a>
35
+ <a class="nav-link" href="/true-false">True & False</a>
36
36
  </li>
37
37
  <li class="nav-item">
38
- <a class="nav-link" href="/halunke/function">Function</a>
38
+ <a class="nav-link" href="/function">Function</a>
39
39
  </li>
40
40
  <li class="nav-item">
41
- <a class="nav-link" href="/halunke/class">Class</a>
41
+ <a class="nav-link" href="/class">Class</a>
42
42
  </li>
43
43
  <li class="nav-item">
44
- <a class="nav-link" href="/halunke/stdio">Stdio</a>
44
+ <a class="nav-link" href="/stdio">Stdio</a>
45
45
  </li>
46
46
  <li class="nav-item">
47
- <a class="nav-link" href="/halunke/web">Web</a>
47
+ <a class="nav-link" href="/web">Web</a>
48
48
  </li>
49
49
  </ul>
50
50
  </div>
51
51
  </nav>
52
52
 
53
53
  <header>
54
+ <div class="alert alert-primary" role="alert">
55
+ Halunke is Open Source and on <a href="http://github.com/moonglum/halunke">Github. <a href="http://try.halunke.jetzt">Try out Halunke online!</a>
56
+ </div>
54
57
  <h1>{{ page.title }}</h1>
55
58
  </header>
56
59
  <main>
@@ -44,6 +44,19 @@ length with the results of the function calls.
44
44
  ([0 1 2] map { |'x| (x + 1) }) /* => [1 2 3] */
45
45
  ```
46
46
 
47
+ ## `find else`
48
+
49
+ Calls the provided function for each element. Returns the first element for
50
+ which the function returns true. If none of the calls returns true, it will
51
+ return the fallback value.
52
+
53
+ **Example:**
54
+
55
+ ```
56
+ (["a" "b" "c"] find { |'el| (el = "a") } else "not found")
57
+ /* => "a" */
58
+ ```
59
+
47
60
  ## `to_s`
48
61
 
49
62
  This returns a string to represent the array in output.
@@ -27,6 +27,13 @@ gem install halunke
27
27
 
28
28
  You can start a REPL with `halunke` or run a file with `halunke file.hal`.
29
29
 
30
+ Alternatively (if you don't have Ruby installed for example), you
31
+ can run it with Docker:
32
+
33
+ ```
34
+ docker run --rm -ti bascht/halunke
35
+ ```
36
+
30
37
  ## How it works
31
38
 
32
39
  In Halunke, everything is an object. And you can send messages to Objects.
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{The Halunke programming language}
13
13
  spec.description = %q{A dynamic OO language with ideas traditionally described as "functional"}
14
- spec.homepage = "https://moonglum.github.io/halunke"
14
+ spec.homepage = "http://halunke.jetzt"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -17,6 +17,7 @@ module Halunke
17
17
  @root_context["Array"] = Halunke::Runtime::HArray
18
18
  @root_context["Dictionary"] = Halunke::Runtime::HDictionary
19
19
  @root_context["UnassignedBareword"] = Halunke::Runtime::HUnassignedBareword
20
+ @root_context["Regexp"] = Halunke::Runtime::HRegexp
20
21
  @root_context["stdio"] = Halunke::Runtime::HStdio.create_instance
21
22
  @root_context["web"] = Halunke::Runtime::HWeb.create_instance
22
23
 
@@ -7,5 +7,6 @@ require "halunke/runtime/hstring"
7
7
  require "halunke/runtime/harray"
8
8
  require "halunke/runtime/hdictionary"
9
9
  require "halunke/runtime/hunassigned_bareword"
10
+ require "halunke/runtime/hregexp"
10
11
  require "halunke/runtime/hstdio"
11
12
  require "halunke/runtime/hweb"
@@ -18,6 +18,11 @@ module Halunke
18
18
  context["fn"].receive_message(context, "call", [HArray.create_instance([x])])
19
19
  end)
20
20
  }),
21
+ "find else" => HFunction.new([:self, :search_fn, :fallback], lambda { |context|
22
+ context["self"].ruby_value.find(-> { context["fallback"] }) do |element|
23
+ context["search_fn"].receive_message(context, "call", [HArray.create_instance([element])]) == context["true"]
24
+ end
25
+ }),
21
26
  "to_s" => HFunction.new([:self], lambda { |context|
22
27
  inspected_members = context["self"].ruby_value.map do |member|
23
28
  member.receive_message(context, "to_s", []).ruby_value
@@ -56,7 +56,7 @@ module Halunke
56
56
  end
57
57
 
58
58
  def receive_message(context, message_name, message_value)
59
- if message_name == "new"
59
+ if message_name == "new" && !native?
60
60
  create_instance(message_value[0])
61
61
  elsif @class_methods.keys.include? message_name
62
62
  m = @class_methods[message_name]
@@ -0,0 +1,30 @@
1
+ module Halunke
2
+ module Runtime
3
+ HRegexp = HClass.new(
4
+ "Regexp",
5
+ [],
6
+ {
7
+ "inspect" => HFunction.new([:self, :attr], lambda { |context|
8
+ HString.create_instance(context["self"].ruby_value.inspect)
9
+ })
10
+ },
11
+ {
12
+ "new" => HFunction.new([:self, :attr], lambda { |context|
13
+ str = (context["attr"].ruby_value.find do |key, _value|
14
+ key.ruby_value == "string"
15
+ end)[1].ruby_value
16
+
17
+ HRegexp.create_instance(Regexp.new(str))
18
+ }),
19
+ "from" => HFunction.new([:self, :str], lambda { |context|
20
+ context["self"].receive_message(
21
+ context,
22
+ "new",
23
+ [HDictionary.create_instance(HString.create_instance("string") => context["str"])]
24
+ )
25
+ })
26
+ },
27
+ true
28
+ )
29
+ end
30
+ end
@@ -14,6 +14,17 @@ module Halunke
14
14
  )
15
15
  HString.create_instance(result)
16
16
  }),
17
+ "match" => HFunction.new([:self, :regexp], lambda { |context|
18
+ match_data = context["self"].ruby_value.match(context["regexp"].ruby_value)
19
+ h = {}
20
+ match_data.named_captures.each_pair do |key, value|
21
+ h[HString.create_instance(key)] = HString.create_instance(value)
22
+ end
23
+ match_data.to_a.each_with_index do |value, key|
24
+ h[HString.create_instance(key)] = HString.create_instance(value)
25
+ end
26
+ HDictionary.create_instance(h)
27
+ }),
17
28
  "=" => HFunction.new([:self, :other], lambda { |context|
18
29
  if context["self"].ruby_value == context["other"].ruby_value
19
30
  context["true"]
@@ -1,3 +1,3 @@
1
1
  module Halunke
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halunke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Dohmen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-11 00:00:00.000000000 Z
11
+ date: 2018-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -100,6 +100,7 @@ files:
100
100
  - bin/console
101
101
  - bin/setup
102
102
  - docs/.gitignore
103
+ - docs/CNAME
103
104
  - docs/Gemfile
104
105
  - docs/Gemfile.lock
105
106
  - docs/_config.yml
@@ -136,13 +137,14 @@ files:
136
137
  - lib/halunke/runtime/hnative_object.rb
137
138
  - lib/halunke/runtime/hnumber.rb
138
139
  - lib/halunke/runtime/hobject.rb
140
+ - lib/halunke/runtime/hregexp.rb
139
141
  - lib/halunke/runtime/hstdio.rb
140
142
  - lib/halunke/runtime/hstring.rb
141
143
  - lib/halunke/runtime/hunassigned_bareword.rb
142
144
  - lib/halunke/runtime/hweb.rb
143
145
  - lib/halunke/runtime/true.hal
144
146
  - lib/halunke/version.rb
145
- homepage: https://moonglum.github.io/halunke
147
+ homepage: http://halunke.jetzt
146
148
  licenses:
147
149
  - MIT
148
150
  metadata: {}