syntax

Version, currently 0.2.03 versions

github.com/omarroth/syntax.cr

Flexible syntax highlighter

6 stars
0 dependents
License: GPLv3

Nothing has been indexed for 0.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  syntax:
    github: omarroth/syntax.cr
    version: ~> 0.2.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.2.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

# syntax
[![GitHub release](https://img.shields.io/github/release/omarroth/syntax.cr.svg)](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