Add proper README.
This commit is contained in:
parent
e1019a7c23
commit
b4c36f6f5c
29
README.md
29
README.md
|
@ -1,6 +1,6 @@
|
||||||
# lex
|
# lex
|
||||||
|
|
||||||
TODO: Write a description here
|
Use the liblex library to tokenize text.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -9,24 +9,35 @@ Add this to your application's `shard.yml`:
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
lex:
|
lex:
|
||||||
github: your-github-user/lex
|
git: https://dev.danilafe.com/Chip-8-Wizardry/lex.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```crystal
|
```crystal
|
||||||
require "lex"
|
require "lex"
|
||||||
|
|
||||||
|
# Create a lexer
|
||||||
|
lexer = Lex::Lexer.new
|
||||||
|
|
||||||
|
# Add tokens using their regular expression and value.
|
||||||
|
# Tokens with larger value take higher priority.
|
||||||
|
lexer.add_pattern(".", 0) # Matches any one character.
|
||||||
|
lexer.add_pattern("ab+", 1) # Matches ab, abb, abbb...
|
||||||
|
lexer.add_pattern("(ab)+", 2) # Matches ab, abab, ababab...
|
||||||
|
lexer.add_pattern("ab*", 3) # Matches a, ab, abb...
|
||||||
|
lexer.add_pattern("[a-d]", 4) # matches a, b, c, d
|
||||||
|
lexer.add_pattern("[^a-d]", 5) # matches all chars but a, b, c, d
|
||||||
|
|
||||||
|
# Lex some text
|
||||||
|
tokens = lexer.lex "ab abb"
|
||||||
```
|
```
|
||||||
|
|
||||||
TODO: Write usage instructions here
|
An array of tuples of type `Tuple(String, Int32)` is returned.
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
TODO: Write development instructions here
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork it (<https://github.com/your-github-user/lex/fork>)
|
1. Fork it (<https://dev.danilafe.com/Chip-8-Wizardry/lex>)
|
||||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
4. Push to the branch (`git push origin my-new-feature`)
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
@ -34,4 +45,4 @@ TODO: Write development instructions here
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
- [your-github-user](https://github.com/your-github-user) Danila Fedorin - creator, maintainer
|
- [DanilaFe](https://dev.danilafe.com/DanilaFe) Danila Fedorin - creator, maintainer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user