Sha256: d96748a83199ce49ed6f76c372811b9b2caed8ce94492dacec85ec7c469b2d03

Contents?: true

Size: 1.44 KB

Versions: 75

Compression:

Stored size: 1.44 KB

Contents

# begin: ragel
=begin
%%{
  machine bel;

  include 'common.rl';

  action blank_line_yield {
    yield blank_line
  }

  blank = SP*;
  bl_ast := blank NL? @blank_line_yield;
}%%
=end
# end: ragel

require_relative '../ast/node'
require_relative '../mixin/buffer'
require_relative '../nonblocking_io_wrapper'

module BELParser
  module Parsers
    module Common
      module BlankLine

        class << self

          MAX_LENGTH = 1024 * 128 # 128K

          def parse(content)
            return nil unless content

            Parser.new(content).each do |obj|
              yield obj
            end
          end
        end

        private

        class Parser
          include Enumerable
          include BELParser::Parsers::Buffer
          include BELParser::Parsers::AST::Sexp

          def initialize(content)
            @content = content
      # begin: ragel
            %% write data;
      # end: ragel
          end

          def each
            @buffers    = {}
            @incomplete = {}
            data        = @content.unpack('C*')
            p           = 0
            pe          = data.length

      # begin: ragel
            %% write init;
            %% write exec;
      # end: ragel
          end
        end
      end
    end
  end
end

if __FILE__ == $0
  $stdin.each_line do |line|
    BELParser::Parsers::Common::BlankLine.parse(line) { |obj|
      puts obj.inspect
    }
  end
end

# vim: ft=ruby ts=2 sw=2:
# encoding: utf-8

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
bel_parser-1.1.6-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.6 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.5 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.4-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.4 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.3-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.3 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.2-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.2 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.1-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.1.1 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.8-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.8 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.7-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.7 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.6-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.6 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.5-java lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.5 lib/bel_parser/parsers/common/blank_line.rl
bel_parser-1.0.4-java lib/bel_parser/parsers/common/blank_line.rl