Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Update to crystal v0.25.0
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Jun 16, 2018
1 parent b53cc2c commit 46df839
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: jager
version: 0.3.0
version: 0.4.0

authors:
- Omar Roth <[email protected]>

description: |
Reverse regular expression engine
crystal: 0.24.2
crystal: 0.25.0

dependencies:
marpa:
github: omarroth/marpa
branch: master
version: 0.3.0

license: MIT
28 changes: 14 additions & 14 deletions src/jager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,20 @@ module Jager
# Generate a string that matches the given regular expression (as string)
def generate(regex : String)
graph = compile(regex)
output = traverse(graph)
output = generate(graph)

return output
end

# Given graph, create output until an endpoint is found
def generate(graph : Array(Node))
output = ""
offset = 0

until graph[offset][:edges].empty?
output += graph[offset][:value]
offset += graph[offset][:edges].sample(1)[0]
end

return output
end
Expand All @@ -382,18 +395,5 @@ module Jager

return graph
end

# Given graph, make output until an endpoint is found
def traverse(graph : Array(Node))
output = ""
offset = 0

until graph[offset][:edges].empty?
output += graph[offset][:value]
offset += graph[offset][:edges].sample(1)[0]
end

return output
end
end
end

0 comments on commit 46df839

Please sign in to comment.