module ParseTreeComm

require 'yaml' require 'marshal'

Constants

SERIALIZE

Public Instance Methods

get() click to toggle source
# File lib/redparse/parse_tree_server.rb, line 35
def get
  begin
    len=@in.gets.to_i
    msg=@in.read(len)
    @in.getc  #read trailing \n
  rescue Exception
    @in=@out=nil
    raise
  end
  result=SERIALIZE.load msg
  return result
end
put(o) click to toggle source
# File lib/redparse/parse_tree_server.rb, line 24
def put o
  o=SERIALIZE.dump o
  msg= o.size.to_s+"\n"+o+"\n"
  begin
    @out.write msg
    @out.flush
  rescue Exception
    @out=@in=nil
    raise
  end
end