Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automate parser

Check a file from a given grammar.

Requirements

  • Python 3.12 or higher
  • Pipenv (optional)

Usage

python src/main.py <token_defs_path> <rules_path> <file_path> [-v]

Where:

  • token_defs_path is the path to the file containing the token definitions. This file must be a valid JSON file.
  • rules_path is the path to the file containing the grammar rules. This file must follow the format specified in the Grammar section.
  • file_path is the path to the file to be checked.

You can find some examples of token definitions, grammar and sample file in the examples folder.

Grammar

The grammar file must follow this format:

<non-terminal-1> -> <production-1> | <production-2> | ...
<non-terminal-2> -> <production-1> | <production-2> | ...

Where:

  • <non-terminal> is a non-terminal symbol.
  • <production> is a production rule. It can be a terminal symbol, a non-terminal symbol or a sequence of symbols.

The grammar needs at least one non-terminal symbol "S" (start symbol).

Object mapping

If the file match the grammar, you can use a class extending AbstractHandler to build objects from tokens.

This project provides a Spacecom package as an example of how to use this feature.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages