mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
parent
3ed317a441
commit
51ea82a770
1 changed files with 23 additions and 16 deletions
|
@ -3,6 +3,19 @@
|
||||||
# Here we are reopening the prism module to provide methods on nodes that aren't
|
# Here we are reopening the prism module to provide methods on nodes that aren't
|
||||||
# templated and are meant as convenience methods.
|
# templated and are meant as convenience methods.
|
||||||
module Prism
|
module Prism
|
||||||
|
module RegularExpressionOptions
|
||||||
|
# Returns a numeric value that represents the flags that were used to create
|
||||||
|
# the regular expression.
|
||||||
|
def options
|
||||||
|
o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
|
||||||
|
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
|
||||||
|
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
|
||||||
|
o
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private_constant :RegularExpressionOptions
|
||||||
|
|
||||||
class FloatNode < Node
|
class FloatNode < Node
|
||||||
# Returns the value of the node as a Ruby Float.
|
# Returns the value of the node as a Ruby Float.
|
||||||
def value
|
def value
|
||||||
|
@ -24,15 +37,16 @@ module Prism
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class InterpolatedMatchLastLineNode < Node
|
||||||
|
include RegularExpressionOptions
|
||||||
|
end
|
||||||
|
|
||||||
class InterpolatedRegularExpressionNode < Node
|
class InterpolatedRegularExpressionNode < Node
|
||||||
# Returns a numeric value that represents the flags that were used to create
|
include RegularExpressionOptions
|
||||||
# the regular expression.
|
end
|
||||||
def options
|
|
||||||
o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
|
class MatchLastLineNode < Node
|
||||||
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
|
include RegularExpressionOptions
|
||||||
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
|
|
||||||
o
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class RationalNode < Node
|
class RationalNode < Node
|
||||||
|
@ -43,14 +57,7 @@ module Prism
|
||||||
end
|
end
|
||||||
|
|
||||||
class RegularExpressionNode < Node
|
class RegularExpressionNode < Node
|
||||||
# Returns a numeric value that represents the flags that were used to create
|
include RegularExpressionOptions
|
||||||
# the regular expression.
|
|
||||||
def options
|
|
||||||
o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
|
|
||||||
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
|
|
||||||
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
|
|
||||||
o
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class ConstantReadNode < Node
|
class ConstantReadNode < Node
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue