Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library similar to pyparsing in Java? [closed]

I need to quickly build a parser for a very simplified version of a html-like markup language in Java. In python, I would use pyparsing library to do this. Is there something similar for Java? Please, don't suggest libraries already out there for html parsing, my application is a school assignment which will demonstrate walking a tree of objects and serializing to text using visitor pattern, so I'm not thinking in real world terms here. Basically all I need here is tags, attributes and text nodes.

like image 391
VoY Avatar asked Nov 29 '08 14:11

VoY


People also ask

What is parser Python?

The parser module provides an interface to Python's internal parser and byte-code compiler. The primary purpose for this interface is to allow Python code to edit the parse tree of a Python expression and create executable code from this.

How do parser generators work?

A parser generator takes a grammar as input and automatically generates source code that can parse streams of characters using the grammar. The generated code is a parser, which takes a sequence of characters and tries to match the sequence against the grammar.

What is a parser in Java?

A parser is a Java class that extracts attributes from a local file and stores the information in the repository. More specifically, in the case of a document, a parser: Takes in an InputStream or Reader object. Processes the character input, extracting attributes as it goes.

How do you write parser in Java?

There are three ways of parsing in Java: Using an existing library. Using a tool or library to build a parser. By building a custom parser from scratch.


1 Answers

Another good parser generator is ANTLR, that might be what you're looking for.

like image 101
Jorn Avatar answered Sep 19 '22 10:09

Jorn