Class: Minjs::ECMA262::MultiLineComment

Inherits:
Literal show all
Includes:
Ctype
Defined in:
lib/minjs/ecma262/literal.rb

Overview

Class of ECMA262 MultiLineComment Element

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods included from Ctype

#decimal_digit?, #hex_digit?, #identifier_part?, #identifier_start?, #idname?, #line_terminator?, #octal_digit?, #white_space?

Methods inherited from Literal

#priority, #side_effect?

Methods inherited from Base

#add_remove_paren, #concat, #deep_dup, #replace

Constructor Details

#initialize(comment) ⇒ MultiLineComment

Returns a new instance of MultiLineComment.



1134
1135
1136
# File 'lib/minjs/ecma262/literal.rb', line 1134

def initialize(comment)
  @comment = comment
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



1131
1132
1133
# File 'lib/minjs/ecma262/literal.rb', line 1131

def comment
  @comment
end

#has_lfObject (readonly)

Returns the value of attribute has_lf.



1131
1132
1133
# File 'lib/minjs/ecma262/literal.rb', line 1131

def has_lf
  @has_lf
end

Instance Method Details

#==(obj) ⇒ Object

compare object



1145
1146
1147
# File 'lib/minjs/ecma262/literal.rb', line 1145

def ==(obj)
  self.class == obj.class and @comment == obj.comment
end

#lt?Boolean

true if literal is line terminator

If MultiLineComment has one more LineTerminator, This comment is kind of line terminator. otherwise, this comment is kind of white space.

Returns:



1165
1166
1167
1168
1169
1170
# File 'lib/minjs/ecma262/literal.rb', line 1165

def lt?
  @comment.codepoints.each{|char|
    return true if line_terminator?(char)
  }
  false
end

#to_js(options) ⇒ Object

Returns a ECMAScript string containg the representation of element.

See Also:



1151
1152
1153
# File 'lib/minjs/ecma262/literal.rb', line 1151

def to_js(options)
  "/*#{@comment}*/"
end

#traverse(parent, &block) ⇒ Object

Traverses this children and itself with given block.

See Also:



1141
1142
# File 'lib/minjs/ecma262/literal.rb', line 1141

def traverse(parent, &block)
end

#ws?Boolean

true if literal is white space

Returns:



1156
1157
1158
# File 'lib/minjs/ecma262/literal.rb', line 1156

def ws?
  !lt?
end