Skip to content

Commit

Permalink
~Updated readme
Browse files Browse the repository at this point in the history
Updated the readme to clarify the behaviour of select statements
  • Loading branch information
AjaniBilby committed Mar 8, 2023
1 parent a70a5af commit 992570a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.insertSpaces": false,
"[markdown]": {
"files.trimTrailingWhitespace": false
}
}
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 3.1.2
### Fixes:
- [x] Updated readme to clarify behaviour of select statements

## Version 3.1.1
### Fixes:
- [x] Incorrect referencing for syntax errors.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnf-parser",
"version": "3.1.1",
"version": "3.1.2",
"description": "Deterministic BNF compiler/parser",
"main": "./bin/index.js",
"scripts": {
Expand Down
16 changes: 12 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- [Range](#range)
- [Literal](#literal)

A simple library for generate syntax pasers based BNF syntax descriptions.
A simple library for generate syntax pasers based BNF syntax descriptions.
There are a few changes from standard BNF forms to help produce cleaner syntax tree outputs that BNFs normally provide.

# Example
Expand Down Expand Up @@ -126,7 +126,7 @@ The omit character goes in front af a single term, and must be the front most op
!term
```

This operator must be between two single length constants, this will accept all characters within the range of the two bounds (inclusive).
This operator must be between two single length constants, this will accept all characters within the range of the two bounds (inclusive).

### Range `->`

Expand All @@ -135,7 +135,7 @@ This operator must be between two single length constants, this will accept all
"a"->"z"* # will consume as many characters as are in the range
```

This operator must be between two single length constants, this will accept all characters within the range of the two bounds (inclusive). Until the repetition count is reached.
This operator must be between two single length constants, this will accept all characters within the range of the two bounds (inclusive). Until the repetition count is reached.
The first operand must have no repetitions, however the repetition markers on the last operand will apply to the whole group.

## Imports
Expand All @@ -154,7 +154,7 @@ Is initialised with a built syntax tree. Once initialized it can be given input

```ts
class Parser {
constructor(blob: any)
constructor(blob: any)

// Attempts to parse a language into a syntax tree
parse(
Expand Down Expand Up @@ -300,6 +300,14 @@ If there is a repetition marker such as `name+` there will be an extra noded add

Will resolve as the syntax tree of the first matching option. For instance if you have the select statement `variable | number`, if the parser matches a variable it would be the same as having a `variable` at that point in the sequence.

> The select statement will always consume the first valid option, and your should order your select statements accordingly
> i.e.
> ```bnf
> program ::= "a" | "aa" ;
> ```
> Giving this program "aa" will fail, as it will consume the single "a", then since there is no repetition the program will end leaving the second "a" unconsumed. As the syntax did not parse the whole string, this is considered an error.
> See [Parser](#parser) for information on how to allow partial matches

## Omit

Any omit statement within a sequence will be removed, and then looking at the outputted syntax tree it is like they never existed, however they are still critical to a successful match. In the case that they are within a select, they will still be visible with `.type` of `omit`, with no child nodes.
Expand Down

0 comments on commit 992570a

Please sign in to comment.