Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an ANTLR4 grammar for YAML?

Since YAML has a rather complicated syntax, is it possible to write a parser for YAML mainly using ANTLR4 ? I was looking for examples, that implement the YAML like indentation parsing and the detection of data types.

like image 374
JE42 Avatar asked Aug 30 '14 06:08

JE42


People also ask

Is YAML context sensitive?

XML, JSON, and YAML generally fall under context-free or context-sensitive languages depending on how they're used.

What grammar does ANTLR use?

A language is specified using a context-free grammar expressed using Extended Backus–Naur Form (EBNF). ANTLR can generate lexers, parsers, tree parsers, and combined lexer-parsers.

What is antlr4 used for?

What is ANTLR? ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

What is YAML parser?

The Symfony Yaml component parses YAML strings to convert them to PHP arrays. It is also able to convert PHP arrays to YAML strings. YAML, YAML Ain't Markup Language, is a human friendly data serialization standard for all programming languages. YAML is a great format for your configuration files.


1 Answers

The YAML specification contains a BNF grammar. Bear in mind that according to this document, fully correct YAML is context-sensitive and not parseable by parser-generators, so your grammar will have to describe a context-free superset.

like image 166
Ari Fordsham Avatar answered Sep 24 '22 07:09

Ari Fordsham