rgo-lang 0.1.1 → 0.1.4

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.
@@ -55,6 +55,8 @@ module Rgo
55
55
  @q.push [:COMMA, ","]
56
56
  when m = scanner.scan(/\./)
57
57
  @q.push [:DOT, "."]
58
+ when m = scanner.scan(/\:\:/)
59
+ @q.push [:DCOLON, "::"]
58
60
  when m = scanner.scan(/\:/)
59
61
  @q.push [:COLON, ":"]
60
62
  when m = scanner.scan(Expression::INSTANCE_VARIABLE)
@@ -98,7 +100,7 @@ module Rgo
98
100
 
99
101
  INSTANCE_VARIABLE= /\@\w+/
100
102
 
101
- KEYWORDS = /class|end|require|module|def|include|true|false|if|else|elsif|alias|return/
103
+ KEYWORDS = /class|end|require|module|def|include|true|false|if|else|elsif|alias|return|interface/
102
104
  end # Expression
103
105
  end
104
106
  end
@@ -1,3 +1,3 @@
1
1
  module Rgo
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/parse.y CHANGED
@@ -22,6 +22,7 @@ rule
22
22
  : /* NONDE */
23
23
  | comment_statement
24
24
  | module_statement
25
+ | interface_statement
25
26
  | require_statement
26
27
  | func_call
27
28
  | func_def
@@ -54,6 +55,11 @@ rule
54
55
  { Node.new(:module, val[1], val[2]) }
55
56
  ;
56
57
 
58
+ interface_statement
59
+ : KEYWORD_INTERFACE CONSTANT statement_list KEYWORD_END
60
+ { Node.new(:interface, val[1], val[2]) }
61
+ ;
62
+
57
63
  func_call: IDENTIFIER LPAREN args RPAREN { Node.new(:func_call, val[0], val[2]) }
58
64
 
59
65
  args
@@ -90,7 +96,12 @@ rule
90
96
  : IDENTIFIER { Node.new(:variable, val[0]) }
91
97
  ;
92
98
 
93
- include_statement: KEYWORD_INCLUDE CONSTANT { Node.new(:include, val[1]) };
99
+ include_statement: KEYWORD_INCLUDE constant_tree { Node.new(:include, val[1]) };
100
+
101
+ constant_tree
102
+ : CONSTANT { [val[0]] }
103
+ | constant_tree DCOLON constant_tree { [val[0], val[2]].flatten }
104
+ ;
94
105
 
95
106
  comment_statement: COMMENT { Node.new(:comment, val[0]) };
96
107
 
@@ -126,8 +137,13 @@ rule
126
137
  ;
127
138
 
128
139
  class_statement
129
- : KEYWORD_CLASS CONSTANT instance_variables_def methods_def KEYWORD_END
130
- { Node.new(:class, val[1], [val[2], val[3]]) }
140
+ : KEYWORD_CLASS CONSTANT class_body KEYWORD_END
141
+ { Node.new(:class, val[1], [val[2][0], val[2][1]]) }
142
+ ;
143
+
144
+ class_body
145
+ : none { [nil, nil] }
146
+ | instance_variables_def methods_def { val }
131
147
  ;
132
148
 
133
149
  instance_variables_def
@@ -0,0 +1,8 @@
1
+ package main
2
+
3
+ type geometry interface {
4
+
5
+ area() float64
6
+
7
+ perim() float64
8
+ }
@@ -0,0 +1,11 @@
1
+ module Main
2
+ interface Geometry
3
+ # type () -> float64
4
+ def area()
5
+ end
6
+
7
+ # type () -> float64
8
+ def perim()
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ package main
2
+
3
+ import "fmt"
4
+ import "net/http"
5
+
6
+ func hello(w http.ResponseWriter, req *http.Request) {
7
+ fmt.Fprintf(w, "hello")
8
+ }
9
+
10
+ func main() {
11
+ http.HandleFunc("/hello", hello)
12
+ http.ListenAndServe(":8090", nil)
13
+ }
@@ -0,0 +1,14 @@
1
+ module Main
2
+ include Fmt
3
+ include Net::Http
4
+
5
+ # type (ResponseWriter, *Request) -> nil
6
+ def hello(w, req)
7
+ fprintf(w, "hello")
8
+ end
9
+
10
+ def main
11
+ handle_func("/hello", hello)
12
+ listen_and_serve(":8090", nil)
13
+ end
14
+ end
@@ -4,5 +4,8 @@ module Fmt
4
4
 
5
5
  def println()
6
6
  end
7
+
8
+ def fprintf()
9
+ end
7
10
  end
8
11
 
@@ -0,0 +1,3 @@
1
+ module Net
2
+
3
+ end
@@ -0,0 +1,16 @@
1
+ module Net
2
+ module Http
3
+ class Request
4
+ end
5
+
6
+ class ResponseWriter
7
+ end
8
+
9
+
10
+ def handle_func()
11
+ end
12
+
13
+ def listen_and_serve()
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgo-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohsen Alizadeh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc
@@ -64,7 +64,13 @@ files:
64
64
  - samples/6_functions.rgo
65
65
  - samples/7_methods.go
66
66
  - samples/7_methods.rgo
67
+ - samples/8_interfaces.go
68
+ - samples/8_interfaces.rgo
69
+ - samples/example_01_http_servers.go
70
+ - samples/example_01_http_servers.rgo
67
71
  - std/fmt.rgo
72
+ - std/net.rgo
73
+ - std/net/http.rgo
68
74
  homepage: https://github.com/mohsen-alizadeh/rgo-lang
69
75
  licenses:
70
76
  - MIT