Sha256: 0651a4b6f3564f608318fa9f7128e8fd2da60db4de76035e712b69ce8df324c5

Contents?: true

Size: 898 Bytes

Versions: 5

Compression:

Stored size: 898 Bytes

Contents

module Minjs
  module Literal
    #
    # 7.8
    #
    def literal(lex, context)
      lex.eval_lit{
        a = lex.fwd_lit(:hint => :regexp)
        if a.kind_of?(ECMA262::ECMA262Numeric) || a.kind_of?(ECMA262::ECMA262String) || a.kind_of?(ECMA262::ECMA262RegExp)
          a
        else
          nil
        end
      } or lex.eval_lit{
        null_literal(lex, context)
      } or lex.eval_lit{
        boolean_literal(lex, context)
      }
    end

    #
    # 7.8.1
    #
    def null_literal(lex, context)
      if lex.match_lit(ECMA262::ID_NULL)
        ECMA262::Null.get
      else
        nil
      end
    end

    #
    # 7.8.2
    #
    def boolean_literal(lex, context)
      if lex.match_lit(ECMA262::ID_TRUE)
        ECMA262::Boolean.get(:true)
      elsif lex.match_lit(ECMA262::ID_FALSE)
        ECMA262::Boolean.get(:false)
      else
        nil
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
minjs-0.2.2 lib/minjs/literal.rb
minjs-0.2.1 lib/minjs/literal.rb
minjs-0.2.0 lib/minjs/literal.rb
minjs-0.1.10 lib/minjs/literal.rb
minjs-0.1.7 lib/minjs/literal.rb