Skip to content

Commit

Permalink
Doc updates for v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhhollomon committed Feb 13, 2019
1 parent 5b6cccc commit 48d9dc4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ unescape space-like character. Note, this means that the semi-colon at the end
of the definition must be separated from the pattern by at least one space (or
tab, or newline).

A parser terminal may also have a type associated with it. If it does, then a
semantic value will be generated and passed to the parser. The type is given in
angle brackets afte the keyword term :

```
term <int> INTEGER r:[-+]?[0-9]+ ;
```

The computation is given as an action encased in `<%{ ... }%>` . If an action
is given, then the normal terminating semi-colon is not required.

```
term <int> INTEGER r:[-+]?[0-9]+ <%{ return std::stoi(lexeme); }%>
```

The action should be though of as the body of a lambda that returns the
semantic value to be passed back to the parser. The identifier `lexeme` is
available. It is a string that contains the text that was matched by the term's
pattern. If you wish to simply return the string (e.g. for an Identifier term)
then some efficency can be gained by doing so as a move:

```
term <std::string> ID r:[a-z]+ <%{ return std::move(lexeme); }%>
```

#### Lexer Terminals

Lexer terminals are recognized by the the lexer but are not returned. They are
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## On Master

## Release v0.0.2

### Functional Changes
- term/skip are now specified as either single-quote or `r:` strings.
- single-quote strings are matched in the lexer as simple string compares
- `r:` strings are treated as std::regex regular expressions.
- term now takes a type in angle brackets. And can take a semantic action as
well.
- enhancement #6 - The state table can be dumped using -S option.

### Code improvements
- Moved to [Inja template engine](https://github.com/pantor/inja) to generate
Expand Down

0 comments on commit 48d9dc4

Please sign in to comment.