bato 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +100 -0
- data/Rakefile +6 -0
- data/bato.gemspec +26 -0
- data/bin/bato +19 -0
- data/examples/kamusta_mundo.bato +5 -0
- data/lib/bato/core_ext/kernel.rb +6 -0
- data/lib/bato/core_ext/string.rb +6 -0
- data/lib/bato/core_ext.rb +2 -0
- data/lib/bato/ruby_parser_patches.rb +116 -0
- data/lib/bato/tagatala.rb +30 -0
- data/lib/bato/version.rb +3 -0
- data/lib/bato.rb +4 -0
- data/spec/bato/tagatala_spec.rb +126 -0
- data/spec/spec_helper.rb +62 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb4aceb327b5b4e67d0d82ada2fba6d07475e1e9
|
4
|
+
data.tar.gz: a5fa77691e1de911a63a560fe1645568b75cc379
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81559215a6952d37e784547326ed227fadb7bee971e87cf4ac2765f4cc16116b597d911017f31e5f4f622e81ee74ac72148945b1f213de1b5d3bbb66f7795eaa
|
7
|
+
data.tar.gz: 4d1afa4c8de1764586a80b8e1154e1efd96e3cd48317121af7f7a32dbc1e9d321bd986f267cc4159e43b2f22efa0b31809af0971017c0b5659fd7b7532ecf767
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Joel Bryan Juliano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Bato
|
2
|
+
|
3
|
+
Ang 'Bato' ay ang unang programming language sa wikang Tagalog.
|
4
|
+
|
5
|
+
## Pagtatalaga
|
6
|
+
|
7
|
+
Kailangan mo munang i-install ang Ruby programming language (version 1.9.3 o mas bago)
|
8
|
+
at pagkatapos maitalaga ang Ruby, i-run naman ito
|
9
|
+
|
10
|
+
gem install bato
|
11
|
+
|
12
|
+
## Bakit Bato?
|
13
|
+
|
14
|
+
Ang 'bato' ay hango sa [Ruby Programming Language](http://www.ruby-lang.org/) na may Tagalog na sintaks.
|
15
|
+
Ang kadahilanang ginamit ang pangalang 'bato' ay dahil ang Ruby ay isang uri ng bato.
|
16
|
+
|
17
|
+
## Ang unang program
|
18
|
+
|
19
|
+
Gumawa ng isang file na kamusta_mundo.bato na may mga sumusunod na nilalaman
|
20
|
+
|
21
|
+
kapag 1 > 0
|
22
|
+
isulat "Kamusta mundo!"
|
23
|
+
kung_hindi
|
24
|
+
isulat "Mayroong sira"
|
25
|
+
katapusan
|
26
|
+
|
27
|
+
at pa-andarin ang program sa pamamagitan ng
|
28
|
+
|
29
|
+
bato kamusta_mundo.bato
|
30
|
+
|
31
|
+
## Sintaks
|
32
|
+
|
33
|
+
### Bilang
|
34
|
+
|
35
|
+
Pambuong Bilang
|
36
|
+
|
37
|
+
123
|
38
|
+
|
39
|
+
Hating Bilang
|
40
|
+
|
41
|
+
123.45
|
42
|
+
|
43
|
+
### Pagsusulat
|
44
|
+
|
45
|
+
"Ito ay mga serye ng mga sulat sa wikang Tagalog"
|
46
|
+
<<-KATAPUSAN
|
47
|
+
mga salita
|
48
|
+
na nahahati
|
49
|
+
sa ilang mga hilera
|
50
|
+
KATAPUSAN
|
51
|
+
|
52
|
+
### Dinikit na mga pamamaraan
|
53
|
+
'magandang araw'.baliktad # => 'wara gnadnagam'
|
54
|
+
'Pangungusap'.haba # => 11
|
55
|
+
|
56
|
+
### Ekspresyong Boolean
|
57
|
+
|
58
|
+
tama
|
59
|
+
mali
|
60
|
+
hindi tama
|
61
|
+
|
62
|
+
### Kondisyon
|
63
|
+
|
64
|
+
Paggamit ng kondisyon.
|
65
|
+
|
66
|
+
kapag halaga > 100 dapat
|
67
|
+
"ayos lang"
|
68
|
+
kung_kapag halaga > 0 dapat
|
69
|
+
"ok lang"
|
70
|
+
kung_hindi
|
71
|
+
"wala lang"
|
72
|
+
katapusan
|
73
|
+
|
74
|
+
kung_sakaling bilang
|
75
|
+
pagka 5 dapat "lima"
|
76
|
+
pagka 4 dapat "apat"
|
77
|
+
kung_hindi "wala"
|
78
|
+
katapusan
|
79
|
+
|
80
|
+
### Pamamaraan sa pagkakamali
|
81
|
+
|
82
|
+
bilang_ng_pagkakamali = 0
|
83
|
+
simula
|
84
|
+
# mag komento kapag hindi sigurado
|
85
|
+
1 / 0
|
86
|
+
iligtas => pagkakamali
|
87
|
+
bilang_ng_pagkakamali += 1
|
88
|
+
subukang_muli kapag bilang_ng_pagkakamali < 3
|
89
|
+
iangat "malubhang pagkakamali"
|
90
|
+
siguraduhing
|
91
|
+
isulat "Tapos na"
|
92
|
+
katapusan
|
93
|
+
|
94
|
+
## Pagtulong sa pagdedevelop ng Bato
|
95
|
+
|
96
|
+
Magpadala ng mga kahilingan sa paggawa ng ticket.
|
97
|
+
|
98
|
+
## Lisensya
|
99
|
+
|
100
|
+
Masasyusets Institut Ng Tekonolohiya licence (makikita sa LICENSE.txt na file).
|
data/Rakefile
ADDED
data/bato.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bato/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bato"
|
8
|
+
spec.version = Bato::VERSION
|
9
|
+
spec.authors = ["Joel Bryan Juliano"]
|
10
|
+
spec.email = ["joelbryan.juliano@gmail.com"]
|
11
|
+
spec.description = %q{Bato Programming Language}
|
12
|
+
spec.summary = %q{Ang Bato ay isang programming language sa wikang Tagalog}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "ruby2ruby"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
data/bin/bato
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "bato/tagatala"
|
5
|
+
|
6
|
+
if pangalan_ng_file = ARGV[0]
|
7
|
+
tagatala = Bato::Tagatala.new
|
8
|
+
kodigo = File.read pangalan_ng_file, encoding: 'utf-8'
|
9
|
+
ruby_kodigo = tagatala.sa_ruby kodigo
|
10
|
+
eval ruby_kodigo
|
11
|
+
|
12
|
+
else
|
13
|
+
puts <<-EOS
|
14
|
+
Hindi tinukoy ang file. Ang tamang sintaks ay:
|
15
|
+
|
16
|
+
bato file.bato
|
17
|
+
EOS
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
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
|
+
def parse_number
|
11
|
+
self.lex_state = :expr_end
|
12
|
+
|
13
|
+
case
|
14
|
+
when src.scan(/[+-]?0[xXbBdD]\b/) then
|
15
|
+
rb_compile_error "Invalid numeric format"
|
16
|
+
# when src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\.\d)\b|0[Dd][0-9_]+)/) then
|
17
|
+
when src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\,\d)\b|0[Dd][0-9_]+)/) then
|
18
|
+
int_with_base(10)
|
19
|
+
when src.scan(/[+-]?0x[a-f0-9_]+/i) then
|
20
|
+
int_with_base(16)
|
21
|
+
when src.scan(/[+-]?0[Bb][01_]+/) then
|
22
|
+
int_with_base(2)
|
23
|
+
when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then
|
24
|
+
rb_compile_error "Illegal octal digit."
|
25
|
+
when src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/) then
|
26
|
+
int_with_base(8)
|
27
|
+
when src.scan(/[+-]?[\d_]+_(e|\.)/) then
|
28
|
+
rb_compile_error "Trailing '_' in number."
|
29
|
+
# when src.scan(/[+-]?[\d_]+\.[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i) then
|
30
|
+
when src.scan(/[+-]?[\d_]+\,[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i) then
|
31
|
+
number = src.matched.sub(',', '.')
|
32
|
+
if number =~ /__/ then
|
33
|
+
rb_compile_error "Invalid numeric format"
|
34
|
+
end
|
35
|
+
self.yacc_value = number.to_f
|
36
|
+
:tFLOAT
|
37
|
+
when src.scan(/[+-]?[0-9_]+(?![e])/) then
|
38
|
+
int_with_base(10)
|
39
|
+
else
|
40
|
+
rb_compile_error "Bad number format"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
module RubyParserStuff
|
47
|
+
class Keyword
|
48
|
+
wordlist = [
|
49
|
+
["katapusan", [:kEND, :kEND ], :expr_end ],
|
50
|
+
["kung_hindi", [:kELSE, :kELSE ], :expr_beg ],
|
51
|
+
["kung_sakaling", [:kCASE, :kCASE ], :expr_beg ],
|
52
|
+
["siguraduhing", [:kENSURE, :kENSURE ], :expr_beg ],
|
53
|
+
["module", [:kMODULE, :kMODULE ], :expr_beg ],
|
54
|
+
["ngunit_kapag", [:kELSIF, :kELSIF ], :expr_beg ],
|
55
|
+
["kung_kapag", [:kELSIF, :kELSIF ], :expr_beg ],
|
56
|
+
["def", [:kDEF, :kDEF ], :expr_fname ],
|
57
|
+
["iligtas", [:kRESCUE, :kRESCUE_MOD ], :expr_mid ],
|
58
|
+
["hindi", [:kNOT, :kNOT ], :expr_beg ],
|
59
|
+
["dapat", [:kTHEN, :kTHEN ], :expr_beg ],
|
60
|
+
["yield", [:kYIELD, :kYIELD ], :expr_arg ],
|
61
|
+
["for", [:kFOR, :kFOR ], :expr_beg ],
|
62
|
+
["self", [:kSELF, :kSELF ], :expr_end ],
|
63
|
+
["mali", [:kFALSE, :kFALSE ], :expr_end ],
|
64
|
+
["subukang_muli", [:kRETRY, :kRETRY ], :expr_end ],
|
65
|
+
["return", [:kRETURN, :kRETURN ], :expr_mid ],
|
66
|
+
["tama", [:kTRUE, :kTRUE ], :expr_end ],
|
67
|
+
["kapag", [:kIF, :kIF_MOD ], :expr_beg ],
|
68
|
+
["defined?", [:kDEFINED, :kDEFINED ], :expr_arg ],
|
69
|
+
["super", [:kSUPER, :kSUPER ], :expr_arg ],
|
70
|
+
["undef", [:kUNDEF, :kUNDEF ], :expr_fname ],
|
71
|
+
["break", [:kBREAK, :kBREAK ], :expr_mid ],
|
72
|
+
["in", [:kIN, :kIN ], :expr_beg ],
|
73
|
+
["do", [:kDO, :kDO ], :expr_beg ],
|
74
|
+
["nil", [:kNIL, :kNIL ], :expr_end ],
|
75
|
+
["until", [:kUNTIL, :kUNTIL_MOD ], :expr_beg ],
|
76
|
+
["unless", [:kUNLESS, :kUNLESS_MOD ], :expr_beg ],
|
77
|
+
["or", [:kOR, :kOR ], :expr_beg ],
|
78
|
+
["next", [:kNEXT, :kNEXT ], :expr_mid ],
|
79
|
+
["pagka", [:kWHEN, :kWHEN ], :expr_beg ],
|
80
|
+
["redo", [:kREDO, :kREDO ], :expr_end ],
|
81
|
+
["and", [:kAND, :kAND ], :expr_beg ],
|
82
|
+
["simula", [:kBEGIN, :kBEGIN ], :expr_beg ],
|
83
|
+
["__LINE__", [:k__LINE__, :k__LINE__ ], :expr_end ],
|
84
|
+
["class", [:kCLASS, :kCLASS ], :expr_class ],
|
85
|
+
["__FILE__", [:k__FILE__, :k__FILE__ ], :expr_end ],
|
86
|
+
["END", [:klEND, :klEND ], :expr_end ],
|
87
|
+
["BEGIN", [:klBEGIN, :klBEGIN ], :expr_end ],
|
88
|
+
["while", [:kWHILE, :kWHILE_MOD ], :expr_beg ],
|
89
|
+
["alias", [:kALIAS, :kALIAS ], :expr_fname ],
|
90
|
+
["__ENCODING__", [:k__ENCODING__, :k__ENCODING__], :expr_end],
|
91
|
+
].map { |args| KWtable.new(*args) }
|
92
|
+
|
93
|
+
# :startdoc:
|
94
|
+
|
95
|
+
original_verbosity = $VERBOSE
|
96
|
+
$VERBOSE = nil
|
97
|
+
|
98
|
+
WORDLIST18 = Hash[*wordlist.map { |o| [o.name, o] }.flatten]
|
99
|
+
WORDLIST19 = Hash[*wordlist.map { |o| [o.name, o] }.flatten]
|
100
|
+
|
101
|
+
$VERBOSE = original_verbosity
|
102
|
+
|
103
|
+
WORDLIST18.delete "__ENCODING__"
|
104
|
+
|
105
|
+
%w[and kung_sakaling ngunit_kapag kung_kapag for kapag in module or unless until pagka while].each do |k|
|
106
|
+
WORDLIST19[k] = WORDLIST19[k].dup
|
107
|
+
WORDLIST19[k].state = :expr_value
|
108
|
+
end
|
109
|
+
%w[hindi].each do |k|
|
110
|
+
WORDLIST19[k] = WORDLIST19[k].dup
|
111
|
+
WORDLIST19[k].state = :expr_arg
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'ruby2ruby'
|
4
|
+
require 'ruby_parser'
|
5
|
+
require 'bato/ruby_parser_patches'
|
6
|
+
|
7
|
+
module Bato
|
8
|
+
|
9
|
+
class Tagatala
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
PASIMULANG_KODIGO = "# encoding: utf-8\nrequire \"bato/core_ext\"\n"
|
16
|
+
|
17
|
+
def sa_ruby(kodigo)
|
18
|
+
ruby2ruby = Ruby2Ruby.new
|
19
|
+
parser = RubyParser.new
|
20
|
+
sexp = parser.process("# encoding: utf-8\n#{kodigo}")
|
21
|
+
|
22
|
+
ruby_kodigo = ruby2ruby.process(sexp)
|
23
|
+
|
24
|
+
"#{PASIMULANG_KODIGO}#{ruby_kodigo}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
data/lib/bato/version.rb
ADDED
data/lib/bato.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
isalaysay_ang "Tagatala" do
|
5
|
+
italaga_ang(:pasimulang_kodigo) do
|
6
|
+
"# encoding: utf-8\nrequire \"bato/core_ext\"\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
italaga_ang(:tagatala) do
|
10
|
+
Bato::Tagatala.new
|
11
|
+
end
|
12
|
+
|
13
|
+
ito_ang "walang lamang program na Bato" do
|
14
|
+
tagatala.sa_ruby("").should == pasimulang_kodigo + ""
|
15
|
+
end
|
16
|
+
|
17
|
+
isalaysay_ang "bilang" do
|
18
|
+
ito_ang "pambuong bilang" do
|
19
|
+
tagatala.sa_ruby("1").should == pasimulang_kodigo + "1"
|
20
|
+
end
|
21
|
+
|
22
|
+
ito_ang "maliliit na bilang" do
|
23
|
+
tagatala.sa_ruby("1.2").should == pasimulang_kodigo + "1.2"
|
24
|
+
end
|
25
|
+
|
26
|
+
ito_ang "listahan ng mga bilang" do
|
27
|
+
tagatala.sa_ruby("[1.2, 3]").should == pasimulang_kodigo + "[1.2, 3]"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
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
|
+
end
|
35
|
+
|
36
|
+
ito_ang "ekspresyon ng mali o false" do
|
37
|
+
tagatala.sa_ruby("mali").should == pasimulang_kodigo + "false"
|
38
|
+
end
|
39
|
+
|
40
|
+
ito_ang "ekspresyon ng hindi o not" do
|
41
|
+
tagatala.sa_ruby("hindi tama").should == pasimulang_kodigo + "(not true)"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
isalaysay_ang "susing mga salita" do
|
47
|
+
ito_ang "ekspresyon ng kapag / dapat / kung_kapag / kung_hindi / katapusan" do
|
48
|
+
tagatala.sa_ruby('
|
49
|
+
kapag 1 dapat
|
50
|
+
2
|
51
|
+
kung_kapag 3
|
52
|
+
4
|
53
|
+
kung_hindi
|
54
|
+
5
|
55
|
+
katapusan'
|
56
|
+
).should be_like(pasimulang_kodigo +
|
57
|
+
'1 ? (2) : (3 ? (4) : (5))'
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
ito_ang "ekspresyon ng kung_sakaling / pagka / dapat / kung_hindi / katapusan" do
|
62
|
+
tagatala.sa_ruby("
|
63
|
+
kung_sakaling 1
|
64
|
+
pagka 1 dapat 1
|
65
|
+
pagka 2
|
66
|
+
2
|
67
|
+
kung_hindi
|
68
|
+
3
|
69
|
+
katapusan"
|
70
|
+
).should be_like(pasimulang_kodigo +
|
71
|
+
'case 1
|
72
|
+
when 1 then
|
73
|
+
1
|
74
|
+
when 2 then
|
75
|
+
2
|
76
|
+
else
|
77
|
+
3
|
78
|
+
end'
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
ito_ang "simula / iligtas / iangat / siguraduhing / katapusan" do
|
83
|
+
# raise ir Kernel metode nevis atslēgvārds
|
84
|
+
tagatala.sa_ruby('
|
85
|
+
simula
|
86
|
+
1 / 0
|
87
|
+
iligtas => pagkakamali
|
88
|
+
subukang_muli
|
89
|
+
iangat pagkakamali, pagkakamali.iulat
|
90
|
+
siguraduhing
|
91
|
+
isulat "Katapusan"
|
92
|
+
katapusan'
|
93
|
+
).should be_like(pasimulang_kodigo +
|
94
|
+
'begin
|
95
|
+
(1 / 0)
|
96
|
+
rescue => pagkakamali
|
97
|
+
retry
|
98
|
+
iangat(pagkakamali, pagkakamali.iulat)
|
99
|
+
ensure
|
100
|
+
isulat("Katapusan")
|
101
|
+
end'
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
isalaysay_ang "pamamaraan sa Kernel" do
|
108
|
+
ito_ang "ekspresyon ng pagsusulat gamit ang 'isulat'" do
|
109
|
+
tagatala.sa_ruby("isulat 'abc'").should ==
|
110
|
+
pasimulang_kodigo + "isulat(\"abc\")"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
isalaysay_ang "Dinikit na mga pamamaraan" do
|
115
|
+
ito_ang "ekspresyon ng pamamaraan sa pagbabaliktad ng mga titik" do
|
116
|
+
resulta = eval tagatala.sa_ruby("'magandang araw'.baliktad")
|
117
|
+
resulta.should == 'wara gnadnagam'
|
118
|
+
end
|
119
|
+
|
120
|
+
ito_ang "ekspresayon ng pamamaraan sa pagsukat ng haba ng salita" do
|
121
|
+
resulta = eval tagatala.sa_ruby("'Pangungusap'.haba")
|
122
|
+
resulta.should == 11
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
5
|
+
# loaded once.
|
6
|
+
#
|
7
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
+
|
9
|
+
module Matchers
|
10
|
+
class BeLike
|
11
|
+
def initialize(expected)
|
12
|
+
@expected = expected.gsub(/^\s+/, '').strip
|
13
|
+
end
|
14
|
+
|
15
|
+
def matches?(actual)
|
16
|
+
@actual = actual.gsub(/^\s+/, '').strip
|
17
|
+
@expected == @actual
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message
|
21
|
+
"expected\n#{@actual}\nto be like\n#{@expected}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def negative_failure_message
|
25
|
+
"expected\n#{@actual}\nto be unlike\n#{@expected}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def be_like(expected)
|
30
|
+
BeLike.new(expected)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec.configure do |config|
|
35
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
36
|
+
config.run_all_when_everything_filtered = true
|
37
|
+
config.filter_run :focus
|
38
|
+
|
39
|
+
# Run specs in random order to surface order dependencies. If you find an
|
40
|
+
# order dependency and want to debug it, you can fix the order by providing
|
41
|
+
# the seed, which is printed after each run.
|
42
|
+
# --seed 1234
|
43
|
+
config.order = 'random'
|
44
|
+
|
45
|
+
include Matchers
|
46
|
+
end
|
47
|
+
|
48
|
+
class << RSpec::Core::ExampleGroup
|
49
|
+
alias_method :isalaysay_ang, :describe
|
50
|
+
RSpec::Core::ExampleGroup.define_example_group_method :isalaysay_ang
|
51
|
+
RSpec::Core::ExampleGroup.define_example_method :ito_ang
|
52
|
+
end
|
53
|
+
|
54
|
+
RSpec::Core::MemoizedHelpers::ClassMethods.module_eval do
|
55
|
+
alias_method :italaga_ang, :let
|
56
|
+
end
|
57
|
+
|
58
|
+
RSpec::Core::MemoizedHelpers.module_eval do
|
59
|
+
alias_method :dapat, :should
|
60
|
+
end
|
61
|
+
|
62
|
+
require 'bato/tagatala'
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joel Bryan Juliano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby2ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Bato Programming Language
|
70
|
+
email:
|
71
|
+
- joelbryan.juliano@gmail.com
|
72
|
+
executables:
|
73
|
+
- bato
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bato.gemspec
|
85
|
+
- bin/bato
|
86
|
+
- examples/kamusta_mundo.bato
|
87
|
+
- lib/bato.rb
|
88
|
+
- lib/bato/core_ext.rb
|
89
|
+
- lib/bato/core_ext/kernel.rb
|
90
|
+
- lib/bato/core_ext/string.rb
|
91
|
+
- lib/bato/ruby_parser_patches.rb
|
92
|
+
- lib/bato/tagatala.rb
|
93
|
+
- lib/bato/version.rb
|
94
|
+
- spec/bato/tagatala_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Ang Bato ay isang programming language sa wikang Tagalog
|
120
|
+
test_files:
|
121
|
+
- spec/bato/tagatala_spec.rb
|
122
|
+
- spec/spec_helper.rb
|