Commit a4ed5e49 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Prototype of @cfg tag implemented as a class.

parent 6479097a
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
module JsDuck::Builtins
  # Implementation of @cfg tag.
  class Cfg
    def initialize
      @pattern = "cfg"
    end

    def parse(p)
      p.add_tag(:cfg)
      p.maybe_type
      p.maybe_name_with_default
      maybe_required(p)
    end

    # matches: "(required)"
    def maybe_required(p)
      p.skip_horiz_white
      if p.look(/\(required\)/i)
        p.match(/\(required\)/i)
        p.current_tag[:optional] = false
      end
    end
  end
end