Sha256: 2f9ffa89fdf9e96514f30f3f40a2df44996f3a796c3c829aaadc542e262f5a0b

Contents?: true

Size: 898 Bytes

Versions: 3

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.new(:true)
      elsif lex.match_lit(ECMA262::ID_FALSE)
        ECMA262::Boolean.new(:false)
      else
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minjs-0.1.5 lib/minjs/literal.rb
minjs-0.1.3 lib/minjs/literal.rb
minjs-0.1.2 lib/minjs/literal.rb