alphalang 0.2.4 β 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/alphalang +1 -1
- data/lib/locale_lister.rb +3 -2
- data/lib/locales/emoji +18 -0
- data/lib/nodes/basenodes.rb +14 -39
- data/lib/nodes/scopemanager.rb +5 -1
- data/lib/nodes/stmtnodes.rb +13 -10
- data/lib/tester/demo_emoji.alpha +19 -0
- data/lib/tester/demo_emoji.alpha~ +0 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dbe6c0cb099f96c68feadb26492b409cdb71d2db52fd5e6436a6c142d273584
|
4
|
+
data.tar.gz: 215b6ea3d011610dbdb3d2021025c29361df8d6cc4dba74a7a8dabf0d7596fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99ce78b496f2eb91ddb26c799fe51e18e5fb0f2d23d546fcadff0cc7a293c28af455ecad577d43b1e9c4e156f781d17b9ba4b4f7f856861158b68301c23ef77
|
7
|
+
data.tar.gz: d6fd552131866752356ce35a82c1ce032dc1863597b1ba618e9f9924fc1d9c2c86a8e595fe64358757156150125ba937350bd422e5818f77f453be9be0882a1a
|
data/bin/alphalang
CHANGED
@@ -5,7 +5,7 @@ require_relative '../lib/rdparse'
|
|
5
5
|
ALPHA_VER = '0.1.5'.freeze
|
6
6
|
ABORT_ANSWERS = [' ', '', 'none', 'abort'].freeze
|
7
7
|
LOCALES_PATH = File.join(__dir__, '../lib/locales')
|
8
|
-
PROTECTED_LOCALES = ['.', '..', 'locale_template', 'default', 'default.old', 'en', 'sv', 'de'].freeze
|
8
|
+
PROTECTED_LOCALES = ['.', '..', 'locale_template', 'default', 'default.old', 'en', 'sv', 'de', 'emoji'].freeze
|
9
9
|
|
10
10
|
basic_error_msg = "Usage: alphalang [options] file.alpha\nUsage: alphalang -h for the help menu."
|
11
11
|
|
data/lib/locale_lister.rb
CHANGED
@@ -20,10 +20,11 @@ def clean_locale_file_to_array(locale_name)
|
|
20
20
|
|
21
21
|
clean_locale_file_array = []
|
22
22
|
locale_file.each do |line|
|
23
|
-
line.scan(
|
24
|
-
clean_locale_file_array << word if word.size > 1
|
23
|
+
line.scan(/[\p{Word}\p{Emoji}]+[|][\p{Word}\p{Emoji}]+|[\p{Word}\p{Emoji}]+/) do |word|
|
24
|
+
clean_locale_file_array << word if word.size > 1 or word.match?(/\p{Emoji}/)
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
27
28
|
clean_locale_file_array
|
28
29
|
end
|
29
30
|
|
data/lib/locales/emoji
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
;;.*$ ;;.*$
|
2
|
+
while π
|
3
|
+
print π¨οΈ
|
4
|
+
pause βΈοΈ
|
5
|
+
def π₯
|
6
|
+
end π
|
7
|
+
if β
|
8
|
+
elseif β
|
9
|
+
else βοΈ
|
10
|
+
(false|true) (π|π)
|
11
|
+
(==|<=|>=) (==|<=|>=)
|
12
|
+
(not|!) (β|!)
|
13
|
+
(and|&&) (π€|&&)
|
14
|
+
(or|\|\|) (βοΈ|\|\|)
|
15
|
+
\s+ \s+
|
16
|
+
\d+ \d+
|
17
|
+
\w+ \w+
|
18
|
+
. .
|
data/lib/nodes/basenodes.rb
CHANGED
@@ -2,30 +2,6 @@
|
|
2
2
|
|
3
3
|
####################################################
|
4
4
|
|
5
|
-
class TrueClass
|
6
|
-
def evaluate
|
7
|
-
self
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class FalseClass
|
12
|
-
def evaluate
|
13
|
-
self
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class String
|
18
|
-
def name
|
19
|
-
self
|
20
|
-
end
|
21
|
-
|
22
|
-
def evaluate
|
23
|
-
self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
####################################################
|
28
|
-
|
29
5
|
class Node
|
30
6
|
attr_accessor :value
|
31
7
|
|
@@ -58,7 +34,6 @@ end
|
|
58
34
|
|
59
35
|
class BoolNode < Node
|
60
36
|
def initialize(value)
|
61
|
-
@value = false
|
62
37
|
@value = true if value == ScopeManager.true_value
|
63
38
|
@value = false if value == ScopeManager.false_value
|
64
39
|
end
|
@@ -69,32 +44,32 @@ class BoolNode < Node
|
|
69
44
|
end
|
70
45
|
|
71
46
|
class AndNode < Node
|
72
|
-
def initialize(
|
73
|
-
@
|
74
|
-
if @
|
75
|
-
if @
|
76
|
-
@
|
47
|
+
def initialize(lhs, rhs)
|
48
|
+
@lhs, @rhs = lhs, rhs
|
49
|
+
if @rhs.class.method_defined? (:lhs)
|
50
|
+
if @rhs.lhs == nil
|
51
|
+
@rhs.lhs = @lhs.lhs
|
77
52
|
end
|
78
53
|
end
|
79
54
|
end
|
80
55
|
|
81
56
|
def evaluate
|
82
|
-
@
|
57
|
+
@lhs.evaluate && @rhs.evaluate
|
83
58
|
end
|
84
59
|
end
|
85
60
|
|
86
61
|
class OrNode < Node
|
87
|
-
def initialize(
|
88
|
-
@
|
89
|
-
if @
|
90
|
-
if @
|
91
|
-
@
|
62
|
+
def initialize(lhs, rhs)
|
63
|
+
@lhs, @rhs = lhs, rhs
|
64
|
+
if @rhs.class.method_defined? (:lhs)
|
65
|
+
if @rhs.lhs == nil
|
66
|
+
@rhs.lhs = @lhs.lhs
|
92
67
|
end
|
93
68
|
end
|
94
69
|
end
|
95
70
|
|
96
71
|
def evaluate
|
97
|
-
@
|
72
|
+
@lhs.evaluate || @rhs.evaluate
|
98
73
|
end
|
99
74
|
end
|
100
75
|
|
@@ -113,8 +88,8 @@ end
|
|
113
88
|
class CompareNode < Node
|
114
89
|
attr_accessor :lhs, :op, :rhs
|
115
90
|
|
116
|
-
def initialize(
|
117
|
-
@lhs, @op, @rhs =
|
91
|
+
def initialize(lhs, op, rhs)
|
92
|
+
@lhs, @op, @rhs = lhs, op, rhs
|
118
93
|
end
|
119
94
|
|
120
95
|
def evaluate
|
data/lib/nodes/scopemanager.rb
CHANGED
@@ -56,7 +56,11 @@ class ScopeManager
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.add_to_current_scope(name, value)
|
59
|
-
|
59
|
+
if name.is_a?(String)
|
60
|
+
@@scopes[@@scope_lvl][name] = value.evaluate
|
61
|
+
else
|
62
|
+
@@scopes[@@scope_lvl][name.name] = value.evaluate
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
def self.add_func_to_global_scope(name, value, args)
|
data/lib/nodes/stmtnodes.rb
CHANGED
@@ -94,32 +94,28 @@ class IfNode < Node
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def evaluate
|
97
|
-
|
98
|
-
@value = @node.evaluate
|
99
|
-
else
|
100
|
-
@value = nil
|
101
|
-
end
|
102
|
-
@value
|
97
|
+
@value = @node.evaluate
|
103
98
|
end
|
104
99
|
end
|
105
100
|
|
106
101
|
class ElseifNode < Node
|
107
102
|
attr_accessor :argument
|
103
|
+
|
108
104
|
def initialize(argument, node)
|
109
105
|
@argument, @node = argument, node
|
110
106
|
end
|
107
|
+
|
111
108
|
def evaluate
|
112
|
-
|
113
|
-
@value = @node.evaluate
|
114
|
-
end
|
109
|
+
@value = @node.evaluate
|
115
110
|
end
|
116
111
|
end
|
117
112
|
|
118
113
|
class ElseNode < Node
|
119
114
|
attr_accessor :argument, :node
|
115
|
+
|
120
116
|
def initialize(node)
|
121
117
|
@node = node
|
122
|
-
@argument =
|
118
|
+
@argument = BoolNode.new(ScopeManager.true_value)
|
123
119
|
end
|
124
120
|
|
125
121
|
def evaluate
|
@@ -194,6 +190,13 @@ class PrintNode
|
|
194
190
|
print "Array #{@value.name}: "
|
195
191
|
puts @value.evaluate.join(', ')
|
196
192
|
else
|
193
|
+
if @value.evaluate == PrintNode
|
194
|
+
if @value.value.is_a?(VariableCallNode)
|
195
|
+
raise SyntaxError, "You have a duplicate 'print' statement! Printing #{@value.value.name} twice."
|
196
|
+
else
|
197
|
+
raise SyntaxError, "You have a duplicate 'print' statement! Printing #{@value.value} twice."
|
198
|
+
end
|
199
|
+
end
|
197
200
|
puts @value.evaluate
|
198
201
|
end
|
199
202
|
self.class
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphalang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mattias, victor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/locale_lister.rb
|
67
67
|
- lib/locales/de
|
68
68
|
- lib/locales/default
|
69
|
+
- lib/locales/emoji
|
69
70
|
- lib/locales/en
|
70
71
|
- lib/locales/locale_template
|
71
72
|
- lib/locales/sv
|
@@ -74,6 +75,8 @@ files:
|
|
74
75
|
- lib/nodes/stmtnodes.rb
|
75
76
|
- lib/rdparse.rb
|
76
77
|
- lib/tester/demo_de.alpha
|
78
|
+
- lib/tester/demo_emoji.alpha
|
79
|
+
- lib/tester/demo_emoji.alpha~
|
77
80
|
- lib/tester/demo_sv.alpha
|
78
81
|
- lib/tester/fibonacci.alpha
|
79
82
|
- lib/tester/test_unit.rb
|