Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
olduh29 committed Nov 4, 2022
1 parent ca4f331 commit b148ec0
Showing 1 changed file with 57 additions and 18 deletions.
75 changes: 57 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,69 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/b3b00/cslycli/blob/main/LICENSE.md)
[![NuGet](https://img.shields.io/nuget/v/csly-cli.svg?kill_cache=1)](https://www.nuget.org/packages/csly-cli)

## Presentation

CSLY CLI is a CLI companion tool for [CSLY](https://github.com/b3b00/csly). It helps quickly test a CSLY lexer/parser without the need to code it.
It describes the lexer/parser as a text file (ala yacc) with dedicated notations for CSLY specificities.

C# sources can also be generated to bootstrap real development using the prototyped parser.

## installation

```
dotnet too install csly-cli
```

## usage

There is 2 usages of csly-cli :
-


### testing the parser

the test command tries to parse a source file according to a grammar specification file and produces :
- error messages if
- grammar specification is erroneous.
- source file does not comply to grammar.
- the syntax tree produced by the parser in 2 possible format
- json (maybe for direct use)
- graphviz dot for visualization (i personnaly use [Graphviz online](https://dreampuf.github.io/GraphvizOnline/)

```csly-cli test``` :
- -g --grammar * : path to grammar specification file
- -s --source * : path to source file to parse
- -o --output : output folder for syntax tree files
- -f --format : [JSON|DOT] syntax tree file formats (many format may be specified separated by space)


if no ouput is provided then CLSY-CLI display if parse succeeded and errors in case of failure.

**examples**
```
csly-cli test -g myGrammar.txt --source mySource.txt -o ./outputDir -f JSON DOT
```
try to parse mySource.txt according to grammar myGrammar.txt and output the syntax tree to outputDir/mySource.json (JSon) and outputDir/mySource.dot (Graphviz dot)

```
csly-cli test -g myGrammar.txt --source mySource.txt
```
try to parse mySource.txt according to grammar myGrammar.txt and output success or errors.

### generating C# sources

```csly-cli generate``` :

- -g --grammar * : path to grammar specification file
- -n --namespace * : parser namespace
- -o --output * : parser output type




## parser specification file format

### specification formal grammar using csly-cli specification file (going meta :) )

genericLexer;

Expand Down Expand Up @@ -103,23 +160,5 @@ genericLexer;
statementPrim: PRINT dynamicParser_expressions;
```
# CSLY CLI arguments
## testing the parser

parse :
- -g --grammar * : chemin vers le fichier grammaire
- -s --source * : chemin vers le fichier source
- -o --output : chemin vers le fichier sortie
- -f --format : [json|dot] format du fichier de sortie

if no ouput is provided then CLSY-CLI display if parse succeeded and errors in case of failure.

## generating C# sources

generate :

- -g --grammar * : chemin vers le fichier grammaire
- -n --namespace * : parser namespace
- -t --type * : parser output type

0 comments on commit b148ec0

Please sign in to comment.