Skip to content

ujihisa/srap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Srap: strscan wrapper

Srap helps you write tokenizer quickly and easily with less idioms.

before

require 'strscan'
s = StringScanner.new c
in_comment = false
a_stack = []
memo = []
until s.eos?
  memo <<
    case
    when s.scan(/.../)
      [:aaa, s[0]]
    ...
end
memo #=> that's what you want

after

require 'srap'
Srap(c).with(in_comment: false, a_stack: []) {|s|
  case
  when s.scan(/.../)
    [:aaa, s[0]]
  ...
} #=> that's what you want

install

$ gem install srap

There's no dependency RubyGems library.

Author

Tatsuhiro Ujihisa

About

strscan wrapper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages