bato 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -3
- data/bato.gemspec +16 -16
- data/bin/bato +4 -4
- data/lib/bato.rb +2 -3
- data/lib/bato/bersiyon.rb +3 -0
- data/lib/bato/core_ext.rb +7 -7
- data/lib/bato/core_ext/array.rb +15 -17
- data/lib/bato/core_ext/class.rb +1 -3
- data/lib/bato/core_ext/enumerator.rb +2 -4
- data/lib/bato/core_ext/integer.rb +4 -0
- data/lib/bato/core_ext/kernel.rb +4 -6
- data/lib/bato/core_ext/range.rb +5 -7
- data/lib/bato/core_ext/string.rb +12 -10
- data/lib/bato/ruby_parser_patches.rb +138 -152
- data/lib/bato/tagatala.rb +2 -11
- data/{examples → mga_halimbawa}/agapan.bato +0 -0
- data/{examples → mga_halimbawa}/dapat.bato +0 -0
- data/{examples → mga_halimbawa}/kontrol-sa-pagiikot.bato +0 -0
- data/{examples/kamusta_mundo.bato → mga_halimbawa/kumusta_mundo.bato} +1 -1
- data/{examples → mga_halimbawa}/magbibigay.bato +0 -0
- data/{examples → mga_halimbawa}/modyul.bato +0 -0
- data/{examples → mga_halimbawa}/ngunit_kapag.bato +0 -0
- data/{examples → mga_halimbawa}/pamamaraan-sa-pagkakamali.bato +0 -0
- data/{examples → mga_halimbawa}/pangalan.bato +0 -0
- data/{examples → mga_halimbawa}/panuntunan.bato +0 -0
- data/{examples → mga_halimbawa}/para_sa.bato +0 -0
- data/{examples → mga_halimbawa}/pibonasyi.bato +0 -0
- data/{examples → mga_halimbawa}/siguraduhin.bato +0 -0
- data/spec/bato/tagatala_spec.rb +34 -43
- data/spec/spec_helper.rb +2 -2
- metadata +31 -31
- data/lib/bato/core_ext/fixnum.rb +0 -5
- data/lib/bato/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3857215397e97cd5db2f2a2f8cdc98ca2870657
|
4
|
+
data.tar.gz: 5612fa1e18f564f935ce7cb033b81670f30cab2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71cd674fe2b0ddcd77f517874d6b38e3c452d48adce600dabba61bb4c3b7d2f03dfd542beda799b04130e20396c54af629e4faf36f99c44cad7a7f6c0f39f721
|
7
|
+
data.tar.gz: 708e80d77142360dfde4d0481eacacfe2360bff75f8cbd9809daffba39608b307bd1c58c561dfc6f4e1f379e3812a4fc6b7f3a934d781f495b3c2daa5751273f
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Ang kadahilanang ginamit ang pangalang 'bato' ay dahil ang Ruby ay isang uri ng
|
|
19
19
|
Gumawa ng isang file na kamusta_mundo.bato na may mga sumusunod na nilalaman
|
20
20
|
|
21
21
|
kapag 1 > 0
|
22
|
-
isulat "
|
22
|
+
isulat "Kumusta mundo!"
|
23
23
|
kung_hindi
|
24
24
|
isulat "Mayroong sira"
|
25
25
|
katapusan
|
data/Rakefile
CHANGED
data/bato.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'bato/
|
4
|
+
require 'bato/bersiyon'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version = Bato::
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
7
|
+
spec.name = 'bato'
|
8
|
+
spec.version = Bato::BERSIYON
|
9
|
+
spec.authors = ['Joel Bryan Juliano']
|
10
|
+
spec.email = ['joelbryan.juliano@gmail.com']
|
11
|
+
spec.description = 'Bato Programming Language'
|
12
|
+
spec.summary = 'Ang Bato ay isang programming language sa wikang Tagalog'
|
13
|
+
spec.homepage = 'https://github.com/jjuliano/bato'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'ruby2ruby', '~> 2.4'
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.2'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
26
26
|
end
|
data/bin/bato
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
require "bato/tagatala"
|
2
|
+
require 'bato/tagatala'
|
3
|
+
require 'rubygems'
|
5
4
|
|
6
5
|
if pangalan_ng_file = ARGV[0]
|
7
6
|
tagatala = Bato::Tagatala.new
|
8
7
|
kodigo = File.read pangalan_ng_file, encoding: 'utf-8'
|
9
8
|
ruby_kodigo = tagatala.sa_ruby kodigo
|
9
|
+
raise 'Ang pinakamababang kinakailangan bersiyon ng Ruby ay 2.4.1' if
|
10
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.1')
|
10
11
|
eval ruby_kodigo
|
11
|
-
|
12
12
|
else
|
13
13
|
puts <<-EOS
|
14
14
|
Hindi tinukoy ang file. Ang tamang sintaks ay:
|
data/lib/bato.rb
CHANGED
data/lib/bato/core_ext.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require 'bato/core_ext/kernel'
|
2
|
+
require 'bato/core_ext/string'
|
3
|
+
require 'bato/core_ext/array'
|
4
|
+
require 'bato/core_ext/enumerator'
|
5
|
+
require 'bato/core_ext/integer'
|
6
|
+
require 'bato/core_ext/range'
|
7
|
+
require 'bato/core_ext/class'
|
data/lib/bato/core_ext/array.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
class Array
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
2
|
+
alias umikot cycle
|
3
|
+
alias isuksok inject
|
4
|
+
alias magbagsak drop
|
5
|
+
alias itulak push
|
6
|
+
alias pasok push
|
7
|
+
alias ipasok push
|
8
|
+
alias huli last
|
9
|
+
alias dulo last
|
10
|
+
alias una first
|
11
|
+
alias isaisahin each
|
12
|
+
alias kada each
|
13
|
+
alias bawat each
|
14
|
+
alias kada_isa each
|
15
|
+
alias sa_bawat_isa each
|
16
|
+
end
|
data/lib/bato/core_ext/class.rb
CHANGED
data/lib/bato/core_ext/kernel.rb
CHANGED
data/lib/bato/core_ext/range.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
class Range
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
2
|
+
alias isaisahin each
|
3
|
+
alias bawat each
|
4
|
+
alias sa_bawat_isa each
|
5
|
+
alias kada_isa each
|
6
|
+
end
|
data/lib/bato/core_ext/string.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
class String
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
alias baliktad reverse
|
3
|
+
alias haba length
|
4
|
+
alias sa_malaking_titik capitalize
|
5
|
+
alias sa_malalaking_titik upcase
|
6
|
+
alias sa_malaking_mga_titik upcase
|
7
|
+
alias sa_maliliit_na_titik downcase
|
8
|
+
alias sa_maliit_na_mga_titik downcase
|
9
|
+
alias igitna center
|
10
|
+
alias kagatan chomp
|
11
|
+
alias palitan replace
|
12
|
+
alias siyasatin inspect
|
13
|
+
end
|
@@ -1,162 +1,150 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
class RubyLexer
|
4
|
-
##
|
5
|
-
# Parse a number from the input stream.
|
6
|
-
#
|
7
|
-
# @param c The first character of the number.
|
8
|
-
# @return A int constant wich represents a token.
|
9
|
-
|
10
2
|
def parse_number
|
11
3
|
self.lex_state = :expr_end
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
when src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\,\d)\b|0[Dd][0-9_]+)/) then
|
5
|
+
if src.scan(/[+-]?0[xXbBdD]\b/)
|
6
|
+
rb_compile_error 'Invalid numeric format'
|
7
|
+
# elsif src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\.\d)\b|0[Dd][0-9_]+)/)
|
8
|
+
elsif src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\,\d)\b|0[Dd][0-9_]+)/)
|
18
9
|
int_with_base(10)
|
19
|
-
|
10
|
+
elsif src.scan(/[+-]?0x[a-f0-9_]+/i)
|
20
11
|
int_with_base(16)
|
21
|
-
|
12
|
+
elsif src.scan(/[+-]?0[Bb][01_]+/)
|
22
13
|
int_with_base(2)
|
23
|
-
|
24
|
-
rb_compile_error
|
25
|
-
|
14
|
+
elsif src.scan(/[+-]?0[Oo]?[0-7_]*[89]/)
|
15
|
+
rb_compile_error 'Illegal octal digit.'
|
16
|
+
elsif src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/)
|
26
17
|
int_with_base(8)
|
27
|
-
|
18
|
+
elsif src.scan(/[+-]?[\d_]+_(e|\.)/)
|
28
19
|
rb_compile_error "Trailing '_' in number."
|
29
|
-
#
|
30
|
-
|
20
|
+
# elsif src.scan(/[+-]?[\d_]+\.[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i)
|
21
|
+
elsif src.scan(/[+-]?[\d_]+\,[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i)
|
31
22
|
number = src.matched.sub(',', '.')
|
32
|
-
if number =~ /__/
|
33
|
-
rb_compile_error "Invalid numeric format"
|
34
|
-
end
|
23
|
+
rb_compile_error 'Invalid numeric format' if number =~ /__/
|
35
24
|
self.yacc_value = number.to_f
|
36
25
|
:tFLOAT
|
37
|
-
|
26
|
+
elsif src.scan(/[+-]?[0-9_]+(?![e])/)
|
38
27
|
int_with_base(10)
|
39
28
|
else
|
40
|
-
rb_compile_error
|
29
|
+
rb_compile_error 'Bad number format'
|
41
30
|
end
|
42
31
|
end
|
43
|
-
|
44
32
|
end
|
45
33
|
|
46
34
|
module RubyParserStuff
|
47
35
|
class Keyword
|
48
36
|
wordlist = [
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
52
|
-
[
|
53
|
-
[
|
54
|
-
[
|
55
|
-
[
|
56
|
-
[
|
57
|
-
[
|
58
|
-
[
|
59
|
-
[
|
60
|
-
[
|
61
|
-
[
|
62
|
-
[
|
63
|
-
[
|
64
|
-
[
|
65
|
-
[
|
66
|
-
[
|
67
|
-
[
|
68
|
-
[
|
69
|
-
[
|
70
|
-
[
|
71
|
-
[
|
72
|
-
[
|
73
|
-
[
|
74
|
-
[
|
75
|
-
[
|
76
|
-
[
|
77
|
-
[
|
78
|
-
[
|
79
|
-
[
|
80
|
-
[
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
85
|
-
[
|
86
|
-
[
|
87
|
-
[
|
88
|
-
[
|
89
|
-
[
|
90
|
-
[
|
91
|
-
[
|
92
|
-
[
|
93
|
-
[
|
94
|
-
[
|
95
|
-
[
|
96
|
-
[
|
97
|
-
[
|
98
|
-
[
|
99
|
-
[
|
100
|
-
[
|
101
|
-
[
|
102
|
-
[
|
103
|
-
[
|
104
|
-
[
|
105
|
-
[
|
106
|
-
[
|
107
|
-
[
|
108
|
-
[
|
109
|
-
[
|
110
|
-
[
|
111
|
-
[
|
112
|
-
[
|
113
|
-
[
|
114
|
-
[
|
115
|
-
[
|
116
|
-
[
|
117
|
-
[
|
118
|
-
[
|
119
|
-
[
|
120
|
-
[
|
121
|
-
[
|
122
|
-
[
|
123
|
-
[
|
124
|
-
[
|
125
|
-
[
|
126
|
-
[
|
127
|
-
[
|
128
|
-
[
|
129
|
-
[
|
130
|
-
[
|
131
|
-
[
|
132
|
-
[
|
133
|
-
[
|
134
|
-
[
|
135
|
-
[
|
136
|
-
[
|
137
|
-
[
|
138
|
-
[
|
139
|
-
[
|
140
|
-
[
|
141
|
-
[
|
142
|
-
[
|
143
|
-
[
|
144
|
-
[
|
145
|
-
[
|
146
|
-
[
|
147
|
-
[
|
148
|
-
[
|
149
|
-
[
|
150
|
-
[
|
151
|
-
[
|
152
|
-
[
|
153
|
-
[
|
154
|
-
[
|
155
|
-
[
|
156
|
-
[
|
157
|
-
[
|
158
|
-
[
|
159
|
-
[
|
37
|
+
['katapusan', %i[kEND kEND], :expr_end],
|
38
|
+
['dulo', %i[kEND kEND], :expr_end],
|
39
|
+
['wakas', %i[kEND kEND], :expr_end],
|
40
|
+
['iba', %i[kELSE kELSE], :expr_beg],
|
41
|
+
['kung_iba', %i[kELSE kELSE], :expr_beg],
|
42
|
+
['kung_hindi', %i[kELSE kELSE], :expr_beg],
|
43
|
+
['kung_hindi_naman', %i[kELSE kELSE], :expr_beg],
|
44
|
+
['kapag_hindi', %i[kELSE kELSE], :expr_beg],
|
45
|
+
['kapag_hindi_naman', %i[kELSE kELSE], :expr_beg],
|
46
|
+
['kung_hindi_pa', %i[kELSE kELSE], :expr_beg],
|
47
|
+
['kapag_hindi_pa', %i[kELSE kELSE], :expr_beg],
|
48
|
+
['at_kung_hindi', %i[kELSE kELSE], :expr_beg],
|
49
|
+
['at_kapag_hindi', %i[kELSE kELSE], :expr_beg],
|
50
|
+
['at_kung_hindi_naman', %i[kELSE kELSE], :expr_beg],
|
51
|
+
['at_kapag_hindi_naman', %i[kELSE kELSE], :expr_beg],
|
52
|
+
['at_kung_hindi_pa', %i[kELSE kELSE], :expr_beg],
|
53
|
+
['at_kapag_hindi_pa', %i[kELSE kELSE], :expr_beg],
|
54
|
+
['maliban_dito', %i[kELSE kELSE], :expr_beg],
|
55
|
+
['maliban_sa_mga_ito', %i[kELSE kELSE], :expr_beg],
|
56
|
+
['kalagayan', %i[kCASE kCASE], :expr_beg],
|
57
|
+
['kaukulan', %i[kCASE kCASE], :expr_beg],
|
58
|
+
['sakaling', %i[kCASE kCASE], :expr_beg],
|
59
|
+
['sakali', %i[kCASE kCASE], :expr_beg],
|
60
|
+
['kung_sakaling', %i[kCASE kCASE], :expr_beg],
|
61
|
+
['sakali_na', %i[kCASE kCASE], :expr_beg],
|
62
|
+
['kung_sakali_na', %i[kCASE kCASE], :expr_beg],
|
63
|
+
['matiyak', %i[kENSURE kENSURE], :expr_beg],
|
64
|
+
['tiyakin', %i[kENSURE kENSURE], :expr_beg],
|
65
|
+
['tiyaking', %i[kENSURE kENSURE], :expr_beg],
|
66
|
+
['siguraduhing', %i[kENSURE kENSURE], :expr_beg],
|
67
|
+
['siguraduhin', %i[kENSURE kENSURE], :expr_beg],
|
68
|
+
['panigurado', %i[kENSURE kENSURE], :expr_beg],
|
69
|
+
['modyul', %i[kMODULE kMODULE], :expr_beg],
|
70
|
+
['ngunit_kapag', %i[kELSIF kELSIF], :expr_beg],
|
71
|
+
['kung_kapag', %i[kELSIF kELSIF], :expr_beg],
|
72
|
+
['ngunit_kapag_ang', %i[kELSIF kELSIF], :expr_beg],
|
73
|
+
['kung_kapag_ang', %i[kELSIF kELSIF], :expr_beg],
|
74
|
+
['panuntunang', %i[kDEF kDEF], :expr_fname],
|
75
|
+
['panuntunan', %i[kDEF kDEF], :expr_fname],
|
76
|
+
['iligtas', %i[kRESCUE kRESCUE_MOD], :expr_mid],
|
77
|
+
['agapan', %i[kRESCUE kRESCUE_MOD], :expr_mid],
|
78
|
+
['hindi', %i[kNOT kNOT], :expr_beg],
|
79
|
+
['dapat', %i[kTHEN kTHEN], :expr_beg],
|
80
|
+
['bigyang_daan', %i[kYIELD kYIELD], :expr_arg],
|
81
|
+
['magbigay_daan', %i[kYIELD kYIELD], :expr_arg],
|
82
|
+
['para_sa', %i[kFOR kFOR], :expr_beg],
|
83
|
+
['para_ang', %i[kFOR kFOR], :expr_beg],
|
84
|
+
['self', %i[kSELF kSELF], :expr_end],
|
85
|
+
['mali', %i[kFALSE kFALSE], :expr_end],
|
86
|
+
['subukang_muli', %i[kRETRY kRETRY], :expr_end],
|
87
|
+
['ibalik', %i[kRETURN kRETURN], :expr_mid],
|
88
|
+
['ibalik_ang', %i[kRETURN kRETURN], :expr_mid],
|
89
|
+
['magbalik', %i[kRETURN kRETURN], :expr_mid],
|
90
|
+
['magbalik_nang', %i[kRETURN kRETURN], :expr_mid],
|
91
|
+
['isauli', %i[kRETURN kRETURN], :expr_mid],
|
92
|
+
['isauli_ang', %i[kRETURN kRETURN], :expr_mid],
|
93
|
+
['ibigay', %i[kRETURN kRETURN], :expr_mid],
|
94
|
+
['ibigay_ang', %i[kRETURN kRETURN], :expr_mid],
|
95
|
+
['magbigay', %i[kRETURN kRETURN], :expr_mid],
|
96
|
+
['magbigay_nang', %i[kRETURN kRETURN], :expr_mid],
|
97
|
+
['tama', %i[kTRUE kTRUE], :expr_end],
|
98
|
+
['kapag', %i[kIF kIF_MOD], :expr_beg],
|
99
|
+
['kapag_ang', %i[kIF kIF_MOD], :expr_beg],
|
100
|
+
['kapag_na_ang', %i[kIF kIF_MOD], :expr_beg],
|
101
|
+
['kung', %i[kIF kIF_MOD], :expr_beg],
|
102
|
+
['kung_ang', %i[kIF kIF_MOD], :expr_beg],
|
103
|
+
['nakatukoy?', %i[kDEFINED kDEFINED], :expr_arg],
|
104
|
+
['nakasaad?', %i[kDEFINED kDEFINED], :expr_arg],
|
105
|
+
['super', %i[kSUPER kSUPER], :expr_arg],
|
106
|
+
['tanggalin', %i[kUNDEF kUNDEF], :expr_fname],
|
107
|
+
['magtanggal', %i[kUNDEF kUNDEF], :expr_fname],
|
108
|
+
['ihinto', %i[kBREAK kBREAK], :expr_mid],
|
109
|
+
['sa', %i[kIN kIN], :expr_beg],
|
110
|
+
['sa_loob_ng', %i[kIN kIN], :expr_beg],
|
111
|
+
['nasa', %i[kIN kIN], :expr_beg],
|
112
|
+
['na_nasa', %i[kIN kIN], :expr_beg],
|
113
|
+
['na_ganito', %i[kDO kDO], :expr_beg],
|
114
|
+
['nang_ganito', %i[kDO kDO], :expr_beg],
|
115
|
+
['ganito', %i[kDO kDO], :expr_beg],
|
116
|
+
['ganito_gawin', %i[kDO kDO], :expr_beg],
|
117
|
+
['ganito_ang_gagawin', %i[kDO kDO], :expr_beg],
|
118
|
+
['wala', %i[kNIL kNIL], :expr_end],
|
119
|
+
['hanggang', %i[kUNTIL kUNTIL_MOD], :expr_beg],
|
120
|
+
['hanggang_ang', %i[kUNTIL kUNTIL_MOD], :expr_beg],
|
121
|
+
['mapa_hanggang', %i[kUNTIL kUNTIL_MOD], :expr_beg],
|
122
|
+
['malibang', %i[kUNLESS kUNLESS_MOD], :expr_beg],
|
123
|
+
['maliban_na', %i[kUNLESS kUNLESS_MOD], :expr_beg],
|
124
|
+
['maliban_ang', %i[kUNLESS kUNLESS_MOD], :expr_beg],
|
125
|
+
['o', %i[kOR kOR], :expr_beg],
|
126
|
+
['o_ang', %i[kOR kOR], :expr_beg],
|
127
|
+
['sumunod', %i[kNEXT kNEXT], :expr_mid],
|
128
|
+
['kasunod', %i[kNEXT kNEXT], :expr_mid],
|
129
|
+
['pagka', %i[kWHEN kWHEN], :expr_beg],
|
130
|
+
['pagka_ang', %i[kWHEN kWHEN], :expr_beg],
|
131
|
+
['ay', %i[kWHEN kWHEN], :expr_beg],
|
132
|
+
['ulitin', %i[kREDO kREDO], :expr_end],
|
133
|
+
['at_ulitin', %i[kREDO kREDO], :expr_end],
|
134
|
+
['uliting_muli', %i[kREDO kREDO], :expr_end],
|
135
|
+
['at', %i[kAND kAND], :expr_beg],
|
136
|
+
['at_ang', %i[kAND kAND], :expr_beg],
|
137
|
+
['simula', %i[kBEGIN kBEGIN], :expr_beg],
|
138
|
+
['simulan', %i[kBEGIN kBEGIN], :expr_beg],
|
139
|
+
['__LINE__', %i[k__LINE__ k__LINE__], :expr_end],
|
140
|
+
['klase', %i[kCLASS kCLASS], :expr_class],
|
141
|
+
['__FILE__', %i[k__FILE__ k__FILE__], :expr_end],
|
142
|
+
['END', %i[klEND klEND], :expr_end],
|
143
|
+
['BEGIN', %i[klBEGIN klBEGIN], :expr_end],
|
144
|
+
['habang', %i[kWHILE kWHILE_MOD], :expr_beg],
|
145
|
+
['habang_ang', %i[kWHILE kWHILE_MOD], :expr_beg],
|
146
|
+
['alyas', %i[kALIAS kALIAS], :expr_fname],
|
147
|
+
['__ENCODING__', %i[k__ENCODING__ k__ENCODING__], :expr_end]
|
160
148
|
].map { |args| KWtable.new(*args) }
|
161
149
|
|
162
150
|
# :startdoc:
|
@@ -169,20 +157,20 @@ module RubyParserStuff
|
|
169
157
|
|
170
158
|
$VERBOSE = original_verbosity
|
171
159
|
|
172
|
-
WORDLIST18.delete
|
160
|
+
WORDLIST18.delete '__ENCODING__'
|
173
161
|
|
174
162
|
%w[at at_ang
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
163
|
+
kalagayan kaukulan sakaling sakali kung_sakaling sakali_na kung_sakali_na
|
164
|
+
ngunit_kapag kung_kapag ngunit_kapag_ang kung_kapag_ang
|
165
|
+
para_sa para_ang
|
166
|
+
kapag kapag_ang kapag_na_ang kung kung_ang
|
167
|
+
sa sa_loob_ng nasa na_nasa
|
168
|
+
modyul
|
169
|
+
o o_ang
|
170
|
+
malibang maliban_na maliban_ang
|
171
|
+
hanggang hanggang_ang mapa_hanggang
|
172
|
+
pagka pagka_ang ay
|
173
|
+
habang habang_ang].each do |k|
|
186
174
|
WORDLIST19[k] = WORDLIST19[k].dup
|
187
175
|
WORDLIST19[k].state = :expr_value
|
188
176
|
end
|
@@ -190,7 +178,5 @@ module RubyParserStuff
|
|
190
178
|
WORDLIST19[k] = WORDLIST19[k].dup
|
191
179
|
WORDLIST19[k].state = :expr_arg
|
192
180
|
end
|
193
|
-
|
194
181
|
end
|
195
182
|
end
|
196
|
-
|
data/lib/bato/tagatala.rb
CHANGED
@@ -1,18 +1,12 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'ruby2ruby'
|
4
2
|
require 'ruby_parser'
|
5
3
|
require 'bato/ruby_parser_patches'
|
6
4
|
|
7
5
|
module Bato
|
8
|
-
|
9
6
|
class Tagatala
|
7
|
+
def initialize; end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
PASIMULANG_KODIGO = "# encoding: utf-8\nrequire \"bato/core_ext\"\n"
|
9
|
+
PASIMULANG_KODIGO = "# encoding: utf-8\nrequire \"bato/core_ext\"\n".freeze
|
16
10
|
|
17
11
|
def sa_ruby(kodigo)
|
18
12
|
ruby2ruby = Ruby2Ruby.new
|
@@ -23,8 +17,5 @@ module Bato
|
|
23
17
|
|
24
18
|
"#{PASIMULANG_KODIGO}#{ruby_kodigo}"
|
25
19
|
end
|
26
|
-
|
27
20
|
end
|
28
|
-
|
29
21
|
end
|
30
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/bato/tagatala_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
1
|
|
4
|
-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
isalaysay_ang 'Tagatala' do
|
5
5
|
italaga_ang(:pasimulang_kodigo) do
|
6
6
|
"# encoding: utf-8\nrequire \"bato/core_ext\"\n"
|
7
7
|
end
|
@@ -10,41 +10,40 @@ isalaysay_ang "Tagatala" do
|
|
10
10
|
Bato::Tagatala.new
|
11
11
|
end
|
12
12
|
|
13
|
-
ito_ang
|
14
|
-
tagatala.sa_ruby(
|
13
|
+
ito_ang 'walang lamang program na Bato' do
|
14
|
+
tagatala.sa_ruby('').should == pasimulang_kodigo + ''
|
15
15
|
end
|
16
16
|
|
17
|
-
isalaysay_ang
|
18
|
-
ito_ang
|
19
|
-
tagatala.sa_ruby(
|
17
|
+
isalaysay_ang 'bilang' do
|
18
|
+
ito_ang 'pambuong bilang' do
|
19
|
+
tagatala.sa_ruby('1').should == pasimulang_kodigo + '1'
|
20
20
|
end
|
21
21
|
|
22
|
-
ito_ang
|
23
|
-
tagatala.sa_ruby(
|
22
|
+
ito_ang 'maliliit na bilang' do
|
23
|
+
tagatala.sa_ruby('1.2').should == pasimulang_kodigo + '1.2'
|
24
24
|
end
|
25
25
|
|
26
|
-
ito_ang
|
27
|
-
tagatala.sa_ruby(
|
26
|
+
ito_ang 'listahan ng mga bilang' do
|
27
|
+
tagatala.sa_ruby('[1.2, 3]').should == pasimulang_kodigo + '[1.2, 3]'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
isalaysay_ang
|
32
|
-
ito_ang
|
33
|
-
tagatala.sa_ruby(
|
31
|
+
isalaysay_ang 'ekspresyong Boolean' do
|
32
|
+
ito_ang 'ekspresyon ng tama o true' do
|
33
|
+
tagatala.sa_ruby('tama').should == pasimulang_kodigo + 'true'
|
34
34
|
end
|
35
35
|
|
36
|
-
ito_ang
|
37
|
-
tagatala.sa_ruby(
|
36
|
+
ito_ang 'ekspresyon ng mali o false' do
|
37
|
+
tagatala.sa_ruby('mali').should == pasimulang_kodigo + 'false'
|
38
38
|
end
|
39
39
|
|
40
|
-
ito_ang
|
41
|
-
tagatala.sa_ruby(
|
40
|
+
ito_ang 'ekspresyon ng hindi o not' do
|
41
|
+
tagatala.sa_ruby('hindi tama').should == pasimulang_kodigo + '(not true)'
|
42
42
|
end
|
43
|
-
|
44
43
|
end
|
45
44
|
|
46
|
-
isalaysay_ang
|
47
|
-
ito_ang
|
45
|
+
isalaysay_ang 'susing mga salita' do
|
46
|
+
ito_ang 'ekspresyon ng kapag / dapat / kung_kapag / kung_hindi / katapusan' do
|
48
47
|
tagatala.sa_ruby('
|
49
48
|
kapag 1 dapat
|
50
49
|
2
|
@@ -52,13 +51,11 @@ isalaysay_ang "Tagatala" do
|
|
52
51
|
4
|
53
52
|
kung_hindi
|
54
53
|
5
|
55
|
-
katapusan'
|
56
|
-
|
57
|
-
'1 ? (2) : (3 ? (4) : (5))'
|
58
|
-
)
|
54
|
+
katapusan').should be_like(pasimulang_kodigo +
|
55
|
+
'1 ? (2) : (3 ? (4) : (5))')
|
59
56
|
end
|
60
57
|
|
61
|
-
ito_ang
|
58
|
+
ito_ang 'ekspresyon ng kung_sakaling / pagka / dapat / kung_hindi / katapusan' do
|
62
59
|
tagatala.sa_ruby("
|
63
60
|
kung_sakaling 1
|
64
61
|
pagka 1 dapat 1
|
@@ -66,8 +63,7 @@ isalaysay_ang "Tagatala" do
|
|
66
63
|
2
|
67
64
|
kung_hindi
|
68
65
|
3
|
69
|
-
katapusan"
|
70
|
-
).should be_like(pasimulang_kodigo +
|
66
|
+
katapusan").should be_like(pasimulang_kodigo +
|
71
67
|
'case 1
|
72
68
|
when 1 then
|
73
69
|
1
|
@@ -75,11 +71,10 @@ isalaysay_ang "Tagatala" do
|
|
75
71
|
2
|
76
72
|
else
|
77
73
|
3
|
78
|
-
end'
|
79
|
-
)
|
74
|
+
end')
|
80
75
|
end
|
81
76
|
|
82
|
-
ito_ang
|
77
|
+
ito_ang 'simula / iligtas / iangat / siguraduhing / katapusan' do
|
83
78
|
# raise ir Kernel metode nevis atslēgvārds
|
84
79
|
tagatala.sa_ruby('
|
85
80
|
simula
|
@@ -89,8 +84,7 @@ isalaysay_ang "Tagatala" do
|
|
89
84
|
iangat pagkakamali, pagkakamali.iulat
|
90
85
|
siguraduhing
|
91
86
|
isulat "Katapusan"
|
92
|
-
katapusan'
|
93
|
-
).should be_like(pasimulang_kodigo +
|
87
|
+
katapusan').should be_like(pasimulang_kodigo +
|
94
88
|
'begin
|
95
89
|
(1 / 0)
|
96
90
|
rescue => pagkakamali
|
@@ -98,29 +92,26 @@ isalaysay_ang "Tagatala" do
|
|
98
92
|
iangat(pagkakamali, pagkakamali.iulat)
|
99
93
|
ensure
|
100
94
|
isulat("Katapusan")
|
101
|
-
end'
|
102
|
-
)
|
95
|
+
end')
|
103
96
|
end
|
104
|
-
|
105
97
|
end
|
106
98
|
|
107
|
-
isalaysay_ang
|
99
|
+
isalaysay_ang 'pamamaraan sa Kernel' do
|
108
100
|
ito_ang "ekspresyon ng pagsusulat gamit ang 'isulat'" do
|
109
101
|
tagatala.sa_ruby("isulat 'abc'").should ==
|
110
|
-
pasimulang_kodigo +
|
102
|
+
pasimulang_kodigo + 'isulat("abc")'
|
111
103
|
end
|
112
104
|
end
|
113
105
|
|
114
|
-
isalaysay_ang
|
115
|
-
ito_ang
|
106
|
+
isalaysay_ang 'Dinikit na mga pamamaraan' do
|
107
|
+
ito_ang 'ekspresyon ng pamamaraan sa pagbabaliktad ng mga titik' do
|
116
108
|
resulta = eval tagatala.sa_ruby("'magandang araw'.baliktad")
|
117
109
|
resulta.should == 'wara gnadnagam'
|
118
110
|
end
|
119
111
|
|
120
|
-
ito_ang
|
112
|
+
ito_ang 'ekspresayon ng pamamaraan sa pagsukat ng haba ng salita' do
|
121
113
|
resulta = eval tagatala.sa_ruby("'Pangungusap'.haba")
|
122
114
|
resulta.should == 11
|
123
115
|
end
|
124
116
|
end
|
125
|
-
|
126
117
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
3
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
4
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -46,7 +46,7 @@ RSpec.configure do |config|
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class << RSpec::Core::ExampleGroup
|
49
|
-
|
49
|
+
alias isalaysay_ang describe
|
50
50
|
RSpec::Core::ExampleGroup.define_example_group_method :isalaysay_ang
|
51
51
|
RSpec::Core::ExampleGroup.define_example_method :ito_ang
|
52
52
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Bryan Juliano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.7'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.7'
|
69
69
|
description: Bato Programming Language
|
70
70
|
email:
|
71
71
|
- joelbryan.juliano@gmail.com
|
@@ -83,34 +83,34 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- bato.gemspec
|
85
85
|
- bin/bato
|
86
|
-
- examples/agapan.bato
|
87
|
-
- examples/dapat.bato
|
88
|
-
- examples/kamusta_mundo.bato
|
89
|
-
- examples/kontrol-sa-pagiikot.bato
|
90
|
-
- examples/magbibigay.bato
|
91
|
-
- examples/modyul.bato
|
92
|
-
- examples/ngunit_kapag.bato
|
93
|
-
- examples/pamamaraan-sa-pagkakamali.bato
|
94
|
-
- examples/pangalan.bato
|
95
|
-
- examples/panuntunan.bato
|
96
|
-
- examples/para_sa.bato
|
97
|
-
- examples/pibonasyi.bato
|
98
|
-
- examples/siguraduhin.bato
|
99
86
|
- lib/bato.rb
|
87
|
+
- lib/bato/bersiyon.rb
|
100
88
|
- lib/bato/core_ext.rb
|
101
89
|
- lib/bato/core_ext/array.rb
|
102
90
|
- lib/bato/core_ext/class.rb
|
103
91
|
- lib/bato/core_ext/enumerator.rb
|
104
|
-
- lib/bato/core_ext/
|
92
|
+
- lib/bato/core_ext/integer.rb
|
105
93
|
- lib/bato/core_ext/kernel.rb
|
106
94
|
- lib/bato/core_ext/range.rb
|
107
95
|
- lib/bato/core_ext/string.rb
|
108
96
|
- lib/bato/ruby_parser_patches.rb
|
109
97
|
- lib/bato/tagatala.rb
|
110
|
-
-
|
98
|
+
- mga_halimbawa/agapan.bato
|
99
|
+
- mga_halimbawa/dapat.bato
|
100
|
+
- mga_halimbawa/kontrol-sa-pagiikot.bato
|
101
|
+
- mga_halimbawa/kumusta_mundo.bato
|
102
|
+
- mga_halimbawa/magbibigay.bato
|
103
|
+
- mga_halimbawa/modyul.bato
|
104
|
+
- mga_halimbawa/ngunit_kapag.bato
|
105
|
+
- mga_halimbawa/pamamaraan-sa-pagkakamali.bato
|
106
|
+
- mga_halimbawa/pangalan.bato
|
107
|
+
- mga_halimbawa/panuntunan.bato
|
108
|
+
- mga_halimbawa/para_sa.bato
|
109
|
+
- mga_halimbawa/pibonasyi.bato
|
110
|
+
- mga_halimbawa/siguraduhin.bato
|
111
111
|
- spec/bato/tagatala_spec.rb
|
112
112
|
- spec/spec_helper.rb
|
113
|
-
homepage:
|
113
|
+
homepage: https://github.com/jjuliano/bato
|
114
114
|
licenses:
|
115
115
|
- MIT
|
116
116
|
metadata: {}
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.6.13
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Ang Bato ay isang programming language sa wikang Tagalog
|
data/lib/bato/core_ext/fixnum.rb
DELETED
data/lib/bato/version.rb
DELETED