PHPackages                             antlr4/antlr4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. antlr4/antlr4

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antlr4/antlr4
=============

antlr4 runtime

4.7.7(4y ago)718.7k↓28.9%22BSD-3-ClausePHPPHP &gt;=7.1

Since Aug 1Pushed 4y ago3 watchersCompare

[ Source](https://github.com/yar3333/antlr4-php-runtime)[ Packagist](https://packagist.org/packages/antlr4/antlr4)[ RSS](/packages/antlr4-antlr4/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (7)Used By (2)

ANTLR4 runtime for PHP
======================

[](#antlr4-runtime-for-php)

[![Build Status](https://camo.githubusercontent.com/c72eaae1b3827c707ae94fe3dd9e304d009b432914d650421d313c0b0921ff8c/68747470733a2f2f7472617669732d63692e6f72672f796172333333332f616e746c72342e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yar3333/antlr4)[![Latest Stable Version](https://camo.githubusercontent.com/73824a46078a53172b4c97bc071ffb95446b82107270c615c55c084b42cbd645/68747470733a2f2f706f7365722e707567782e6f72672f616e746c72342f616e746c72342f76657273696f6e)](https://packagist.org/packages/antlr4/antlr4)[![Total Downloads](https://camo.githubusercontent.com/3fce9f79567c43494798f9294ac2b5930ad9ed1b53c7786eee716cf67f8b4254/68747470733a2f2f706f7365722e707567782e6f72672f616e746c72342f616e746c72342f646f776e6c6f616473)](https://packagist.org/packages/antlr4/antlr4)

PHP 7.1+ runtime for ANTLR4. See [antlr4-php-workspace](https://github.com/yar3333/antlr4-php-workspace).

Installation
------------

[](#installation)

```
composer require "antlr4/antlr4"

```

Using
-----

[](#using)

Download [ANTLR4 with PHP support](https://github.com/yar3333/antlr4-php-workspace/releases).

Write a grammar file (named `Gram.g4` below).

Generate lexer and parser PHP classes. For example, for Windows:

```
SET CLASSPATH=my-path-to-jar\antlr4-4.7.2-complete.jar;%CLASSPATH%
java org.antlr.v4.Tool -o Generated -Dlanguage=Php -visitor -no-listener -package MyPackage\Generated Gram.g4

```

Write your visitor class:

```
