syntax
Version, currently 0.2.13 versions
- 0.2.1latestSep 28, 2019
- 0.2.0not indexedApr 9, 2020
- 0.1.0not indexedApr 9, 2020
github.com/omarroth/syntax.cr
Flexible syntax highlighter
6 stars
0 dependents
License: GPLv3
Installation
# Add this to your shard.yml
dependencies:
syntax:
github: omarroth/syntax.cr
version: ~> 0.2.1Then run:
shards installshard.yml
- Crystal
0.31.0- License
- GPLv3
- Author
- Omar Roth <omarroth@hotmail.com>
Dependencies
Runtime Dependencies
- marpa~> 0.5.1github: omarroth/marpa
README
# syntax
[](https://github.com/omarroth/syntax.cr/releases)
> This is a project built with [marpa](https://github.com/omarroth/marpa).
Flexible syntax highlighter.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
syntax:
github: omarroth/syntax.cr
```
## Usage
```crystal
require "syntax"
highlighter = Syntax::Highlighter.new
grammar = <<-'END_BNF'
# Grammar from https://metacpan.org/pod/distribution/Marpa-R2/pod/Semantics.pod
:start ::= Expression
Expression ::= Number
| '(' Expression ')' bgcolor => salmon
|| Expression '**' Expression bgcolor => red
|| Expression '*' Expression bgcolor => yellow color => black
| Expression '/' Expression bgcolor => green color => orange
|| Expression '+' Expression bgcolor => blue color => orange
| Expression '-' Expression bgcolor => cyan color => black
Number ~ [\d]+
:discard ~ whitespace
whitespace ~ [\s]+
END_BNF
input = "10 + (6 - 1 / 3) * 2"
highlighter.highlight(input, grammar)
```
## Contributing
1. Fork it (<https://github.com/omarroth/syntax.cr/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [omarroth](https://github.com/omarroth) Omar Roth - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.1- Tagged
- Sep 28, 2019
- Commit
90e12ed5db38- Crystal
0.31.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/omarroth/syntax.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 3