Browse Source

Change AST::Member to AST::PropertyDeclaration

master
Dylan Baker 5 years ago
parent
commit
d163e0774a
4 changed files with 9 additions and 9 deletions
  1. 1
    1
      lib/ahem/ast.rb
  2. 2
    2
      lib/ahem/ast/property_declaration.rb
  3. 3
    3
      lib/ahem/parser.rb
  4. 3
    3
      spec/parser_spec.rb

+ 1
- 1
lib/ahem/ast.rb View File

14
   require 'ahem/ast/hash'
14
   require 'ahem/ast/hash'
15
   require 'ahem/ast/identifier'
15
   require 'ahem/ast/identifier'
16
   require 'ahem/ast/index'
16
   require 'ahem/ast/index'
17
-  require 'ahem/ast/member'
18
   require 'ahem/ast/null'
17
   require 'ahem/ast/null'
19
   require 'ahem/ast/number'
18
   require 'ahem/ast/number'
20
   require 'ahem/ast/operators'
19
   require 'ahem/ast/operators'
20
+  require 'ahem/ast/property_declaration'
21
   require 'ahem/ast/string'
21
   require 'ahem/ast/string'
22
   require 'ahem/ast/unary'
22
   require 'ahem/ast/unary'
23
   require 'ahem/ast/variable_declaration'
23
   require 'ahem/ast/variable_declaration'

lib/ahem/ast/member.rb → lib/ahem/ast/property_declaration.rb View File

1
-class AST::Member
1
+class AST::PropertyDeclaration
2
   attr_reader :name, :is_public
2
   attr_reader :name, :is_public
3
 
3
 
4
   def initialize(name, is_public)
4
   def initialize(name, is_public)
7
   end
7
   end
8
 
8
 
9
   def ==(other)
9
   def ==(other)
10
-    other.is_a?(AST::Member) && other.name == @name &&
10
+    other.is_a?(AST::PropertyDeclaration) && other.name == @name &&
11
       other.is_public == @is_public
11
       other.is_public == @is_public
12
   end
12
   end
13
 end
13
 end

+ 3
- 3
lib/ahem/parser.rb View File

63
 
63
 
64
     eat(TokenKinds::LBRACE)
64
     eat(TokenKinds::LBRACE)
65
 
65
 
66
-    members = Array.new
66
+    property_declarations = Array.new
67
 
67
 
68
     while [TokenKinds::PUBLIC, TokenKinds::PRIVATE].include?(
68
     while [TokenKinds::PUBLIC, TokenKinds::PRIVATE].include?(
69
       @current_token.type
69
       @current_token.type
79
 
79
 
80
       while !at_end && true
80
       while !at_end && true
81
         name = identifier
81
         name = identifier
82
-        members << AST::Member.new(name, is_public)
82
+        property_declarations << AST::PropertyDeclaration.new(name, is_public)
83
         if @current_token.type == TokenKinds::COMMA
83
         if @current_token.type == TokenKinds::COMMA
84
           eat(TokenKinds::COMMA)
84
           eat(TokenKinds::COMMA)
85
         else
85
         else
97
 
97
 
98
     eat(TokenKinds::RBRACE)
98
     eat(TokenKinds::RBRACE)
99
 
99
 
100
-    AST::ClassDefinition.new(class_name, members, methods)
100
+    AST::ClassDefinition.new(class_name, property_declarations, methods)
101
   end
101
   end
102
 
102
 
103
   def conditional
103
   def conditional

+ 3
- 3
spec/parser_spec.rb View File

291
         AST::ClassDefinition.new(
291
         AST::ClassDefinition.new(
292
           AST::Identifier.new('Class'),
292
           AST::Identifier.new('Class'),
293
           [
293
           [
294
-            AST::Member.new(AST::Identifier.new('foo'), true),
295
-            AST::Member.new(AST::Identifier.new('bar'), true),
296
-            AST::Member.new(AST::Identifier.new('baz'), false)
294
+            AST::PropertyDeclaration.new(AST::Identifier.new('foo'), true),
295
+            AST::PropertyDeclaration.new(AST::Identifier.new('bar'), true),
296
+            AST::PropertyDeclaration.new(AST::Identifier.new('baz'), false)
297
           ],
297
           ],
298
           [
298
           [
299
             AST::FunctionDefinition.new(
299
             AST::FunctionDefinition.new(

Loading…
Cancel
Save