class Korekto::Statements

Attributes

heap[R]
symbols[R]
syntax[R]

Public Class Methods

new() click to toggle source
# File lib/korekto/statements.rb, line 4
def initialize
  @statements = []
  @heap = Heap.new(13)
  @symbols = Symbols.new
  @syntax = Syntax.new
end

Public Instance Methods

add(statement,code,title,filename) { || ... } click to toggle source
# File lib/korekto/statements.rb, line 14
def add(statement,code,title,filename)
  c = code[0]; w = c=='W'
  if restatement = @statements.detect{(w or _1.type==c) and _1.to_s==statement}
    case restatement.type
    when 'D','X','S','P','T','C','R'
      @heap.add restatement
    else
      raise Error, "restatement: #{restatement.code}"
    end
    code,_ = restatement.code
    title ||= restatement.title
    return code, title
  end
  statement_number = yield
  statement = Statement.new(statement,code,title,filename,statement_number,self)
  @statements.push statement
  case statement.type
  when 'A','I','E','M','L'
    @symbols.define! statement
  when 'D','X','S'
    @symbols.define! statement
    @heap.add statement
  when 'P','T','C','R'
    @heap.add statement
  end
  return statement.code, statement.title
end
length(= @statements.length) click to toggle source
# File lib/korekto/statements.rb, line 12
  def length = @statements.length

  def add(statement,code,title,filename)
    c = code[0]; w = c=='W'
    if restatement = @statements.detect{(w or _1.type==c) and _1.to_s==statement}
      case restatement.type
      when 'D','X','S','P','T','C','R'
        @heap.add restatement
      else
        raise Error, "restatement: #{restatement.code}"
      end
      code,_ = restatement.code
      title ||= restatement.title
      return code, title
    end
    statement_number = yield
    statement = Statement.new(statement,code,title,filename,statement_number,self)
    @statements.push statement
    case statement.type
    when 'A','I','E','M','L'
      @symbols.define! statement
    when 'D','X','S'
      @symbols.define! statement
      @heap.add statement
    when 'P','T','C','R'
      @heap.add statement
    end
    return statement.code, statement.title
  end
end
type(c) click to toggle source
# File lib/korekto/statements.rb, line 11
  def type(c) = @statements.select{_1.type==c}
  def length = @statements.length

  def add(statement,code,title,filename)
    c = code[0]; w = c=='W'
    if restatement = @statements.detect{(w or _1.type==c) and _1.to_s==statement}
      case restatement.type
      when 'D','X','S','P','T','C','R'
        @heap.add restatement
      else
        raise Error, "restatement: #{restatement.code}"
      end
      code,_ = restatement.code
      title ||= restatement.title
      return code, title
    end
    statement_number = yield
    statement = Statement.new(statement,code,title,filename,statement_number,self)
    @statements.push statement
    case statement.type
    when 'A','I','E','M','L'
      @symbols.define! statement
    when 'D','X','S'
      @symbols.define! statement
      @heap.add statement
    when 'P','T','C','R'
      @heap.add statement
    end
    return statement.code, statement.title
  end
end
end