rpl 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gwenhael Le Moine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-22 00:00:00.000000000 Z
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A language inspired by HP's RPL and https://github.com/louisrubet/rpn/
14
14
  email: gwenhael@le-moine.org
@@ -19,22 +19,30 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/rpl
21
21
  - lib/rpl.rb
22
- - lib/rpl/core/branch.rb
23
- - lib/rpl/core/filesystem.rb
24
- - lib/rpl/core/general.rb
25
- - lib/rpl/core/list.rb
26
- - lib/rpl/core/logarithm.rb
27
- - lib/rpl/core/mode.rb
28
- - lib/rpl/core/operations.rb
29
- - lib/rpl/core/program.rb
30
- - lib/rpl/core/stack.rb
31
- - lib/rpl/core/store.rb
32
- - lib/rpl/core/string.rb
33
- - lib/rpl/core/test.rb
34
- - lib/rpl/core/time-date.rb
35
- - lib/rpl/core/trig.rb
36
22
  - lib/rpl/dictionary.rb
37
23
  - lib/rpl/interpreter.rb
24
+ - lib/rpl/parser.rb
25
+ - lib/rpl/types.rb
26
+ - lib/rpl/types/boolean.rb
27
+ - lib/rpl/types/list.rb
28
+ - lib/rpl/types/name.rb
29
+ - lib/rpl/types/numeric.rb
30
+ - lib/rpl/types/program.rb
31
+ - lib/rpl/types/string.rb
32
+ - lib/rpl/words.rb
33
+ - lib/rpl/words/branch.rb
34
+ - lib/rpl/words/filesystem.rb
35
+ - lib/rpl/words/general.rb
36
+ - lib/rpl/words/logarithm.rb
37
+ - lib/rpl/words/mode.rb
38
+ - lib/rpl/words/operations.rb
39
+ - lib/rpl/words/program.rb
40
+ - lib/rpl/words/stack.rb
41
+ - lib/rpl/words/store.rb
42
+ - lib/rpl/words/string-list.rb
43
+ - lib/rpl/words/test.rb
44
+ - lib/rpl/words/time-date.rb
45
+ - lib/rpl/words/trig.rb
38
46
  homepage: https://github.com/gwenhael-le-moine/rpl.rb
39
47
  licenses:
40
48
  - GPL-3.0
data/lib/rpl/core/list.rb DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RplLang
4
- module Core
5
- module List
6
- def populate_dictionary
7
- super
8
-
9
- @dictionary.add_word( ['→list', '->list'],
10
- 'Lists',
11
- '( … x -- […] ) pack x stacks levels into a list',
12
- proc do
13
- args = stack_extract( [%i[numeric]] )
14
- args = stack_extract( %i[any] * args[0][:value] )
15
-
16
- @stack << { type: :list,
17
- value: args.reverse }
18
- end )
19
-
20
- @dictionary.add_word( ['list→', 'list->'],
21
- 'Lists',
22
- '( […] -- … ) unpack list on stack',
23
- proc do
24
- args = stack_extract( [%i[list]] )
25
-
26
- args[0][:value].each do |elt|
27
- @stack << elt
28
- end
29
- end )
30
- end
31
- end
32
- end
33
- end
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RplLang
4
- module Core
5
- module String
6
- def populate_dictionary
7
- super
8
-
9
- @dictionary.add_word( ['→str', '->str'],
10
- 'String',
11
- '( a -- s ) convert element to string',
12
- proc do
13
- args = stack_extract( [:any] )
14
-
15
- @stack << { type: :string,
16
- value: stringify( args[0] ) }
17
- end )
18
-
19
- @dictionary.add_word( ['str→', 'str->'],
20
- 'String',
21
- '( s -- a ) convert string to element',
22
- proc do
23
- args = stack_extract( [%i[string]] )
24
-
25
- @stack += parse( args[0][:value] )
26
- end )
27
-
28
- @dictionary.add_word( ['chr'],
29
- 'String',
30
- '( n -- c ) convert ASCII character code in stack level 1 into a string',
31
- proc do
32
- args = stack_extract( [%i[numeric]] )
33
-
34
- @stack << { type: :string,
35
- value: args[0][:value].to_i.chr }
36
- end )
37
-
38
- @dictionary.add_word( ['num'],
39
- 'String',
40
- '( s -- n ) return ASCII code of the first character of the string in stack level 1 as a real number',
41
- proc do
42
- args = stack_extract( [%i[string]] )
43
-
44
- @stack << { type: :numeric,
45
- base: 10,
46
- value: args[0][:value].ord }
47
- end )
48
-
49
- @dictionary.add_word( ['size'],
50
- 'String',
51
- '( s -- n ) return the length of the string',
52
- proc do
53
- args = stack_extract( [%i[string]] )
54
-
55
- @stack << { type: :numeric,
56
- base: 10,
57
- value: args[0][:value].length }
58
- end )
59
-
60
- @dictionary.add_word( ['pos'],
61
- 'String',
62
- '( s s -- n ) search for the string in level 1 within the string in level 2',
63
- proc do
64
- args = stack_extract( [%i[string], %i[string]] )
65
-
66
- @stack << { type: :numeric,
67
- base: 10,
68
- value: args[1][:value].index( args[0][:value] ) }
69
- end )
70
-
71
- @dictionary.add_word( ['sub'],
72
- 'String',
73
- '( s n n -- s ) return a substring of the string in level 3',
74
- proc do
75
- args = stack_extract( [%i[numeric], %i[numeric], %i[string]] )
76
-
77
- @stack << { type: :string,
78
- value: args[2][:value][ (args[1][:value] - 1)..(args[0][:value] - 1) ] }
79
- end )
80
-
81
- @dictionary.add_word( ['rev'],
82
- 'String',
83
- '( s -- s ) reverse string',
84
- proc do
85
- args = stack_extract( [%i[string list]] )
86
-
87
- result = args[0]
88
-
89
- case args[0][:type]
90
- when :string
91
- result = { type: :string,
92
- value: args[0][:value].reverse }
93
- when :list
94
- result[:value].reverse!
95
- end
96
-
97
- @stack << result
98
- end )
99
-
100
- @dictionary.add_word( ['split'],
101
- 'String',
102
- '( s c -- … ) split string s on character c',
103
- proc do
104
- args = stack_extract( [%i[string], %i[string]] )
105
-
106
- args[1][:value].split( args[0][:value] ).each do |elt|
107
- @stack << { type: :string,
108
- value: elt }
109
- end
110
- end )
111
- end
112
- end
113
- end
114
- end