Skip to main content

![PyPI](https://img.shields.io/pypi/v/javac-parser.svg) ![PyPI - License](https://img.shields.io/pypi/l/javac-parser.svg) [![Build Status](https://travis-ci.org/naturalness/javac-parser.svg?branch=master)](https://travis-ci.org/naturalness/javac-parser)

Use OpenJDK’s Java parser (“javac”) in Python!

Install

pip install javac-parser

Usage

First, instantiate the server:

`python import javac_parser java = javac_parser.Java() `

Count the number of syntax errors:

`python >>> java.get_num_parse_errors('class Hello {') 1 >>> java.get_num_parse_errors('class Hello { }') 0 `

Get a list of diagnostics for each syntax error:

`python >>> java.check_syntax('class Hello {') [('ERROR', 'compiler.err.premature.eof', 'reached end of file while parsing', 1, 14, 13, 13)]' >>> java.check_syntax('class Hello { }') [] `

Lex (tokenize) Java source code, even if it does not compile:

`python >>> java.lex('class Hello {') [('CLASS', 'class', (1, 0), (1, 5), 'class'), ('IDENTIFIER', 'Hello', (1, 6), (1, 11), 'Hello'), ('LBRACE', '{', (1, 12), (1, 13), '{'), ('EOF', '', (1, 13), (1, 13), 'token.end-of-input')] `

See the docstrings in javac_parser.py or type pydoc javac_parser for more details!

Copying

Copyright (C) 2017, 2018 Joshua Charles Campbell and Eddie Antonio Santos

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Metadata

Release files for javac-parser 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for javac-parser 1.0.0
File Size Uploaded Provenance Actions
javac_parser-1.0.0.tar.gz 3.6 MB Without provenance Details for javac_parser-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for javac-parser 1.0.0
File Interpreter ABI Platform Actions
javac_parser-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for javac_parser-1.0.0-py2.py3-none-any.whl

Total release size: 7.2 MB

Release files / javac_parser-1.0.0.tar.gz

Download URL javac_parser-1.0.0.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
5563da1c1c3237af82020735a1b3e3aacf62f04008e5629f98e330e7d6c4b0c7
BLAKE2b-256 checksum
How to use checksums
79b1a9dad136b86d91fc0b9d4c55a8f5c1cc6c95cf974a111acbc325a83d20fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / javac_parser-1.0.0-py2.py3-none-any.whl

Download URL javac_parser-1.0.0-py2.py3-none-any.whl
Size 3.6 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
30d827cb71310fc39ea85feb758db253e8877e84524b7914f014370918c286da
BLAKE2b-256 checksum
How to use checksums
3a5b78223c9e7465a0f83ee1d5aee7065775f75897350ee9a5f115a8e2d1dfed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for javac-parser 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page