Sha256: 7cae18698cc00428e12fdd83c7bd99a724949eeffb7ddf6f42068fae8de3e09d

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 Bytes

Contents

class Fancy AST {
  class Script : Node {
    read_slots: ('file, 'line, 'body)
    @@stack = []

    def push_script {
      @@stack push(self)
    }

    def pop_script {
      @@stack pop()
    }

    def self current {
      @@stack last()
    }

    def initialize: @line file: @file body: @body

    def bytecode: g {
      pos(g)
      try {
        push_script

        # docs, code = body.expressions.partition do |s|
        #   s.kind_of?(Rubinius::AST::StringLiteral)
        # end

        # if code.empty?
        #   # only literal string found, we have to evaluate to it, not
        #   # use as documentation.
        #   docs, code = [], docs
        # end

        # code.each { |c| c.bytecode(g) }

        @body bytecode: g

        # the docs array has top-level expressions that are
        # simply string literals, we can use them for file-level
        # documentation.
        # TODO: implement file documentation here.
      } finally {
        pop_script
      }
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fancy-0.10.0 lib/compiler/ast/script.fy
fancy-0.9.0 lib/compiler/ast/script.fy
fancy-0.8.0 lib/compiler/ast/script.fy