rgo-lang 0.1.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.
@@ -0,0 +1,15 @@
1
+ package main
2
+
3
+ import "fmt"
4
+
5
+ const name = "constant"
6
+
7
+ func main() {
8
+ fmt.Println(name)
9
+
10
+ const number = 500000000
11
+
12
+ const second_number = 200 / number
13
+
14
+ fmt.Println(second_number)
15
+ }
@@ -0,0 +1,15 @@
1
+ module Main
2
+ include Fmt
3
+
4
+ NAME = "constant"
5
+
6
+ def main
7
+ println(name)
8
+
9
+ NUMBER = 500000000
10
+
11
+ SECOND_NUMBER = 200 / NUMBER
12
+
13
+ println(SECOND_NUMBER)
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ package main
2
+
3
+ import "fmt"
4
+
5
+ func plus(a int, b int) int {
6
+ return a + b
7
+ }
8
+
9
+ func plus_plus(a int, b int, c int) int {
10
+ return a + b + c
11
+ }
12
+
13
+ func main() {
14
+ var res = plus(1, 2)
15
+
16
+ fmt.Println("1 + 2 = ", res)
17
+
18
+ res = plus_plus(1, 2, 3)
19
+
20
+ fmt.Println("1 + 2 + 3 = ", res)
21
+ }
@@ -0,0 +1,23 @@
1
+ module Main
2
+ include Fmt
3
+
4
+ # type (int, int) -> int
5
+ def plus(a, b)
6
+ a + b
7
+ end
8
+
9
+ # type (int, int, int) -> int
10
+ def plus_plus(a, b, c)
11
+ a + b + c
12
+ end
13
+
14
+ def main
15
+ res = plus(1, 2)
16
+
17
+ println("1 + 2 = ", res)
18
+
19
+ res = plus_plus(1, 2, 3)
20
+
21
+ println("1 + 2 + 3 = ", res)
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ package main
2
+
3
+ import "fmt"
4
+
5
+ type rect struct {
6
+ width int
7
+
8
+ height int
9
+
10
+ }
11
+
12
+ func (s *rect) area() int {
13
+ return s.width * s.height
14
+ }
15
+
16
+ func (s *rect) perim() int {
17
+ return 2 * s.width + 2 * s.height
18
+ }
19
+
20
+ func main() {
21
+ var r = rect{width: 10, height: 5}
22
+
23
+ fmt.Println("area: ", r.area())
24
+ fmt.Println("perim: ", r.perim())
25
+ }
@@ -0,0 +1,28 @@
1
+ module Main
2
+ include Fmt
3
+
4
+ class Rect
5
+ # type int
6
+ @width
7
+
8
+ # type int
9
+ @height
10
+
11
+ # type () -> int
12
+ def area
13
+ @width * @height
14
+ end
15
+
16
+ # type () -> int
17
+ def perim
18
+ 2 * @width + 2 * @height
19
+ end
20
+ end
21
+
22
+ def main
23
+ r = Rect.new(width: 10, height: 5)
24
+
25
+ println("area: ", r.area())
26
+ println("perim: ", r.perim())
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+
2
+ module Fmt
3
+ alias puts println
4
+
5
+ def println()
6
+ end
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rgo-lang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mohsen Alizadeh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: racc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.16
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.16
27
+ description: syntax by Ruby, performance by Go
28
+ email:
29
+ - mohsen@alizadeh.us
30
+ executables:
31
+ - rgo
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitattributes"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".travis.yml"
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/console
45
+ - bin/setup
46
+ - exe/rgo
47
+ - lib/rgo.rb
48
+ - lib/rgo/compile.rb
49
+ - lib/rgo/node.rb
50
+ - lib/rgo/parser.rb
51
+ - lib/rgo/tokenizer.rb
52
+ - lib/rgo/version.rb
53
+ - parse.y
54
+ - rgo.gemspec
55
+ - samples/1_hello_world.go
56
+ - samples/1_hello_world.rgo
57
+ - samples/3_variables.go
58
+ - samples/3_variables.rgo
59
+ - samples/4_if_else.go
60
+ - samples/4_if_else.rgo
61
+ - samples/5_constants.go
62
+ - samples/5_constants.rgo
63
+ - samples/6_functions.go
64
+ - samples/6_functions.rgo
65
+ - samples/7_methods.go
66
+ - samples/7_methods.rgo
67
+ - std/fmt.rgo
68
+ homepage: https://github.com/mohsen-alizadeh/rgo-lang
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/mohsen-alizadeh/rgo-lang
73
+ source_code_uri: https://github.com/mohsen-alizadeh/rgo-lang
74
+ changelog_uri: https://github.com/mohsen-alizadeh/rgo-lang
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 2.3.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.0.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: ruby like programming langauge
94
+ test_files: []