Browse Source

Change AST::Member to AST::PropertyDeclaration

master
Dylan Baker 4 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,10 +14,10 @@ module AST
14 14
   require 'ahem/ast/hash'
15 15
   require 'ahem/ast/identifier'
16 16
   require 'ahem/ast/index'
17
-  require 'ahem/ast/member'
18 17
   require 'ahem/ast/null'
19 18
   require 'ahem/ast/number'
20 19
   require 'ahem/ast/operators'
20
+  require 'ahem/ast/property_declaration'
21 21
   require 'ahem/ast/string'
22 22
   require 'ahem/ast/unary'
23 23
   require 'ahem/ast/variable_declaration'

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

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

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

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

+ 3
- 3
spec/parser_spec.rb View File

@@ -291,9 +291,9 @@ RSpec.describe Parser do
291 291
         AST::ClassDefinition.new(
292 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 299
             AST::FunctionDefinition.new(

Loading…
Cancel
Save