Sha256: 9580a59a97da726f2a3568d9aeea81196f2c3c3841f2ec1d0b9405b2eeff721d
Contents?: true
Size: 789 Bytes
Versions: 2
Compression:
Stored size: 789 Bytes
Contents
require 'jsduck/js/rkelly_adapter' require 'jsduck/js/associator' require 'rkelly' module JsDuck module Js # A JavaScript parser implementation that uses RKelly and adapts # its output to be the same as the old Esprima parser used to # produce. class Parser ADAPTER = Js::RKellyAdapter.new def initialize(input, options={}) @input = input end # Parses JavaScript source code with RKelly, turns RKelly AST # into Esprima AST, and associate comments with syntax nodes. def parse ast = RKelly::Parser.new.parse(@input) ast = ADAPTER.adapt(ast) # Adjust Program node range ast["range"] = [0, @input.length-1] return Js::Associator.new(@input).associate(ast) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jsduck-5.0.0 | lib/jsduck/js/parser.rb |
jsduck-5.0.0.beta5 | lib/jsduck/js/parser.rb |