<commit_before># Parser

[![Gem Version](https://badge.fury.io/rb/parser.png)](https://badge.fury.io/rb/parser)
[![Build Status](https://travis-ci.org/whitequark/parser.png?branch=master)](https://travis-ci.org/whitequark/parser)
[![Code Climate](https://codeclimate.com/github/whitequark/parser.png)](https://codeclimate.com/github/whitequark/parser)
[![Coverage Status](https://coveralls.io/repos/whitequark/parser/badge.png?branch=master)](https://coveralls.io/r/whitequark/parser)

_Parser_ is a production-ready Ruby parser written in pure Ruby. It performs on
par or better than Ripper, Melbourne, JRubyParser or ruby\_parser.

You can also use [unparser](https://github.com/mbj/unparser) to produce
equivalent source code from Parser's ASTs.

Sponsored by [Evil Martians](http://evilmartians.com).
MacRuby and RubyMotion support sponsored by [CodeClimate](http://codeclimate.com).

## Installation

    $ gem install parser

## Usage

Parse a chunk of code:

    require 'parser/current'

    p Parser::CurrentRuby.parse("2 + 2")
    # (send
    #   (int 2) :+
    #   (int 2))

Access the AST's source map:

    p Parser::CurrentRuby.parse("2 + 2").loc
    # #<Parser::Source::Map::Send:0x007fe5a1ac2388
    #   @dot=nil,
    #   @begin=nil,<commit_msg>Clarify introduction in README (fixes #210)<commit_after># Parser

[![Gem Version](https://badge.fury.io/rb/parser.png)](https://badge.fury.io/rb/parser)
[![Build Status](https://travis-ci.org/whitequark/parser.png?branch=master)](https://travis-ci.org/whitequark/parser)
[![Code Climate](https://codeclimate.com/github/whitequark/parser.png)](https://codeclimate.com/github/whitequark/parser)
[![Coverage Status](https://coveralls.io/repos/whitequark/parser/badge.png?branch=master)](https://coveralls.io/r/whitequark/parser)

_Parser_ is a production-ready Ruby parser written in pure Ruby. It recognizes as
much or more code than Ripper, Melbourne, JRubyParser or ruby\_parser, and
is vastly more convenient to use.

You can also use [unparser](https://github.com/mbj/unparser) to produce
equivalent source code from Parser's ASTs.

Sponsored by [<NAME>ians](http://evilmartians.com).
MacRuby and RubyMotion support sponsored by [CodeClimate](http://codeclimate.com).

## Installation

    $ gem install parser

## Usage

Parse a chunk of code:

    require 'parser/current'

    p Parser::CurrentRuby.parse("2 + 2")
    # (send
    #   (int 2) :+
    #   (int 2))

Access the AST's source map:

    p Parser::CurrentRuby.parse("2 + 2").loc
    # #<Parser::Source::Map::Send:0x007fe5a1ac2388
    #   @dot=nil,
    #   @begin=nil,
{'fraction_non_alphanumeric': 0.1550327805630544, 'fraction_numerical': 0.01349787890474354, 'mean_word_length': 4.4154488517745305, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6656825', 'n_tokens_mistral': 954, 'n_tokens_neox': 866, 'n_words': 185}