code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'html5/constants'
require 'html5/tokenizer'
require 'html5/treebuilders/rexml'
Dir.glob(File.join(File.dirname(__FILE__), 'html5parser', '*_phase.rb')).each do |path|
require 'html5/html5parser/' + File.basename(path)
end
module HTML5
# Error in parsed document
class ParseError < Exception; end
class... | Ruby |
require 'html5/constants'
require 'html5/inputstream'
module HTML5
# This class takes care of tokenizing HTML.
#
# * @current_token
# Holds the token that is currently being processed.
#
# * @state
# Holds a reference to the method to be invoked... XXX
#
# * @states
# Holds a mapping between... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class AfterBodyPhase < Phase
handle_end 'html'
def processComment(data)
# This is needed because data is to be appended to the <html> element
# here and not to whatever is currently open.
@tree.insert_comment(data, @tree.open_elements.first)
... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InSelectPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-select
handle_start 'html', 'option', 'optgroup', 'select'
handle_start 'input'
handle_end 'option', 'optgroup', 'select', %w( caption table tbody tfoot thead tr td th ... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class AfterHeadPhase < Phase
handle_start 'html', 'body', 'frameset', %w( base link meta script style title ) => 'FromHead'
handle_end %w( body html br ) => 'BodyHtmlBr'
def process_eof
anything_else
@parser.phase.process_eof
end
def p... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InSelectInTablePhase < Phase
handle_start %w(caption table tbody tfoot thead tr td th) => 'Table'
handle_end %w(caption table tbody tfoot thead tr td th) => 'Table'
def processCharacters(data)
@parser.phases[:inSelect].processCharacters(data)
end
... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class AfterAfterFramesetPhase < Phase
handle_start 'html', 'noframes'
def processComment(data)
@tree.insert_comment(data)
end
def processDoctype data
@parser.phases[:inBody].processDoctype(data)
end
def processSpaceCha... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InHeadPhase < Phase
handle_start 'html', 'head', 'title', 'style', 'script', 'noscript'
handle_start %w( base link meta)
handle_end 'head'
handle_end %w( html body br ) => 'ImplyAfterHead'
handle_end %w( title style script noscript )
def... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InForeignContentPhase < Phase
def processCharacters(data)
@tree.insertText(data)
end
def startTagOther(name, attributes, self_closing)
if !%w[mglyph malignmark].include?(name) && %w[mi mo mn ms mtext].include?(@tree.open_elements.last.nam... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class AfterFramesetPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#after3
handle_start 'html', 'noframes'
handle_end 'html'
def processCharacters(data)
parse_error("unexpected-char-after-frameset")
end
def startTagNo... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InColumnGroupPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-column
handle_start 'html', 'col'
handle_end 'colgroup', 'col'
def ignoreEndTagColgroup
@tree.open_elements[-1].name == 'html'
end
def processChar... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InitialPhase < Phase
# This phase deals with error handling as well which is currently not
# covered in the specification. The error handling is typically known as
# "quirks mode". It is expected that a future version of HTML5 will define this.
d... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class AfterAfterBodyPhase < Phase
handle_start 'html'
def processComment(data)
@tree.insert_comment(data)
end
def processDoctype data
@parser.phases[:inBody].processDoctype(data)
end
def processSpaceCharacters data
... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class BeforeHeadPhase < Phase
handle_start 'html', 'head'
handle_end %w( head br ) => 'ImplyHead'
def process_eof
startTagHead('head', {})
@parser.phase.process_eof
end
def processSpaceCharacters(data)
end
def processCharacte... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InCellPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-cell
handle_start 'html', %w( caption col colgroup tbody td tfoot th thead tr ) => 'TableOther'
handle_end %w( td th ) => 'TableCell', %w( body caption col colgroup html ) =... | Ruby |
module HTML5
# Base class for helper objects that implement each phase of processing.
#
# Handler methods should be in the following order (they can be omitted):
#
# * EOF
# * Comment
# * Doctype
# * SpaceCharacters
# * Characters
# * StartTag
# - startTag* methods
# * EndTag
... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InRowPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-row
handle_start 'html', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead tr ) => 'TableOther'
handle_end 'tr', 'table', %w( tbody tfoot thead ) => 'Tab... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InTableBodyPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-table0
handle_start 'html', 'tr', %w( td th ) => 'TableCell', %w( caption col colgroup tbody tfoot thead ) => 'TableOther'
handle_end 'table', %w( tbody tfoot thead ) =... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InTablePhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-table
handle_start 'html', 'caption', 'colgroup', 'col', 'table'
handle_start %w( tbody tfoot thead ) => 'RowGroup', %w( td th tr ) => 'ImplyTbody'
handle_start %w(sty... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InBodyPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-body
handle_start 'html'
handle_start %w(base link meta script style title) => 'ProcessInHead'
handle_start 'body', 'form', 'plaintext', 'a', 'button', 'xmp', 'table', '... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InFramesetPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-frameset
handle_start 'html', 'frameset', 'frame', 'noframes'
handle_end 'frameset', 'noframes'
def processCharacters(data)
parse_error("unexpected-char-in-fr... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class InCaptionPhase < Phase
# http://www.whatwg.org/specs/web-apps/current-work/#in-caption
handle_start 'html', %w(caption col colgroup tbody td tfoot th thead tr) => 'TableElement'
handle_end 'caption', 'table', %w(body col colgroup html tbody td tfoot... | Ruby |
require 'html5/html5parser/phase'
module HTML5
class BeforeHtmlPhase < Phase
def process_eof
insert_html_element
@parser.phase.process_eof
end
def processComment(data)
@tree.insert_comment(data, @tree.document)
end
def processSpaceCharacters(data)
end
def processChar... | Ruby |
require 'html5/treewalkers/base'
require 'rexml/document'
module HTML5
module TreeWalkers
module Hpricot
class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker
def node_details(node)
case node
when ::Hpricot::Elem
if node.name.empty?
[:DOCUMENT_... | Ruby |
require 'html5/treewalkers/base'
require 'rexml/document'
module HTML5
module TreeWalkers
module REXML
class TreeWalker < HTML5::TreeWalkers::NonRecursiveTreeWalker
def node_details(node)
case node
when ::REXML::Document
[:DOCUMENT]
when ::REXML::Element
... | Ruby |
require 'html5/constants'
module HTML5
module TreeWalkers
module TokenConstructor
def error(msg)
{:type => "SerializeError", :data => msg}
end
def normalize_attrs(attrs)
attrs.to_a
end
def empty_tag(name, attrs, has_children=false)
error(_("Void element has children")) if has_children
{:typ... | Ruby |
require 'html5/treewalkers/base'
module HTML5
module TreeWalkers
module SimpleTree
class TreeWalker < HTML5::TreeWalkers::Base
include HTML5::TreeBuilders::SimpleTree
def walk(node)
case node
when Document, DocumentFragment
return
when DocumentTyp... | Ruby |
# HTML 5 conformance checker
#
# Warning: this module is experimental, incomplete, and subject to removal at any time.
#
# Usage:
# >>> from html5lib.html5parser import HTMLParser
# >>> from html5lib.filters.validator import HTMLConformanceChecker
# >>> p = HTMLParser(tokenizer=HTMLConformanceChecker)
# >>> p.parse('... | Ruby |
# borrowed from feedvalidator, original copyright license is
#
# Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the So... | Ruby |
require 'html5/filters/base'
require 'html5/sanitizer'
module HTML5
module Filters
class HTMLSanitizeFilter < Base
include HTMLSanitizeModule
def each
__getobj__.each do |token|
yield(sanitize_token(token))
end
end
end
end
end
| Ruby |
require 'html5/filters/base'
module HTML5
module Filters
class InjectMetaCharset < Base
def initialize(source, encoding)
super(source)
@encoding = encoding
end
def each
state = :pre_head
meta_found = @encoding.nil?
pending = []
__getobj__.each d... | Ruby |
# adapted from feedvalidator, original copyright license is
#
# Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Sof... | Ruby |
require 'html5/constants'
require 'html5/filters/base'
module HTML5
module Filters
class OptionalTagFilter < Base
def slider
previous1 = previous2 = nil
__getobj__.each do |token|
yield previous2, previous1, token if previous1 != nil
previous2 = previous1
prev... | Ruby |
require 'delegate'
require 'enumerator'
module HTML5
module Filters
class Base < SimpleDelegator
include Enumerable
end
end
end
| Ruby |
require 'html5/constants'
require 'html5/filters/base'
module HTML5
module Filters
class WhitespaceFilter < Base
SPACE_PRESERVE_ELEMENTS = %w[pre textarea] + RCDATA_ELEMENTS
SPACES = /[#{SPACE_CHARACTERS.join('')}]+/m
def each
preserve = 0
__getobj__.each do |token|
... | Ruby |
# adapted from feedvalidator, original copyright license is
#
# Copyright (c) 2002-2006, Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Sof... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require "html5/sniffer"
class TestFeedTypeSniffer < Test::Unit::TestCase
include HTML5
include TestSupport
include Sniffer
html5_test_files('sniffer').each do |test_file|
test_name = File.basename(test_file).sub('.test', '')
tests = JSON.parse(F... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require "test/unit"
require "html5/inputstream"
class TestHtml5Inputstream < Test::Unit::TestCase
def test_newline_in_queue
stream = HTML5::HTMLInputStream.new("\nfoo")
stream.unget(stream.char)
assert_equal [1, 0], stream.position
end
def test... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/inputstream'
class HTMLInputStreamTest < Test::Unit::TestCase
include HTML5
def getc stream
if String.method_defined? :force_encoding
stream.char.force_encoding('binary')
else
stream.char
end
end
def test_char_ascii... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/html5parser'
require 'html5/treewalkers'
require 'html5/treebuilders'
$tree_types_to_test = {
'simpletree' =>
{:builder => HTML5::TreeBuilders['simpletree'],
:walker => HTML5::TreeWalkers['simpletree']},
'rexml' =>
{:builder => HTM... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/treebuilders'
require 'html5/html5parser'
require 'html5/cli'
$tree_types_to_test = ['simpletree', 'rexml']
begin
require 'hpricot'
$tree_types_to_test.push('hpricot')
rescue LoadError
end
class Html5ParserTestCase < Test::Unit::TestCase
inc... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/liberalxmlparser'
XMLELEM = /<(\w+\s*)((?:[-:\w]+="[^"]*"\s*)+)(\/?)>/
def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser)
sortattrs = proc {"<#{$1+$2.split.sort.join(' ')+$3}>"}
document = parser.parse(input.chomp, :lowercase_at... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require "html5/cli"
class TestCli < Test::Unit::TestCase
def test_open_input
assert_equal $stdin, HTML5::CLI.open_input('-')
assert_kind_of StringIO, HTML5::CLI.open_input('http://whatwg.org/')
assert_kind_of File, HTML5::CLI.open_input('testdata/site... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/inputstream'
class Html5EncodingTestCase < Test::Unit::TestCase
include HTML5
include TestSupport
begin
require 'rubygems'
require 'UniversalDetector'
def test_chardet #TODO: can we get rid of this?
file = File.open(File.jo... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/tokenizer'
require 'tokenizer_test_parser'
class Html5TokenizerTestCase < Test::Unit::TestCase
def assert_tokens_match(expectedTokens, receivedTokens, ignoreErrorOrder, message)
if !ignoreErrorOrder
assert_equal expectedTokens, receive... | Ruby |
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/html5parser'
require 'html5/liberalxmlparser'
require 'html5/treewalkers'
require 'html5/serializer'
require 'html5/sanitizer'
class SanitizeTest < Test::Unit::TestCase
include HTML5
def sanitize_xhtml stream
XHTMLParse... | Ruby |
require 'html5/constants'
class TokenizerTestParser
def initialize(tokenizer)
@tokenizer = tokenizer
end
def parse
@outputTokens = []
debug = nil
for token in @tokenizer
debug = token.inspect if token[:type] == :ParseError
send(('process' + token[:type].to_s), token)
end
re... | Ruby |
require 'test/unit'
HTML5_BASE = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))
if File.exists?(File.join(HTML5_BASE, 'ruby', 'testdata'))
TESTDATA_DIR = File.join(HTML5_BASE, 'ruby', 'testdata')
else
TESTDATA_DIR = File.join(HTML5_BASE, 'testdata')
end
$:.unshift File.join(File.dirname(Fi... | Ruby |
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5/html5parser'
require 'html5/serializer'
require 'html5/treewalkers'
#Run the serialize error checks
checkSerializeErrors = false
class JsonWalker < HTML5::TreeWalkers::Base
def each
@tree.each do |token|
case token[0]
when 'StartT... | Ruby |
#!/usr/bin/env ruby -wKU
require File.join(File.dirname(__FILE__), 'preamble')
require 'html5'
require 'html5/filters/validator'
class TestValidator < Test::Unit::TestCase
def run_validator_test(test)
p = HTML5::HTMLParser.new(:tokenizer => HTMLConformanceChecker)
p.parse(test['input'])
errorCodes = p.... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
puts "Adding BrokenCompass Version: 1.0"
require "startup"
require "broken_compass"
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the broken_compass plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for ... | Ruby |
require "rubygems"
require "activerecord"
namespace :brokencompass do
desc "Creates indexes"
task :index do
brokencompass_logger ||= Logger.new("#{RAILS_ROOT}/log/brokencompass.log")
brokencompass_logger.info("Starting index creation at #{Time.now}")
if File.exist?(File.join(RAILS_ROOT,"config","bro... | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module ActiveRecord #:nodoc:
class Base
@@bc_logger ||= Logger.new("#{RAILS_ROOT}/log/brokencompass.log")
#Initializing index container if not already initialized
@@broken_compass_index ||= {}
#Loading configurations from config/brokencompass.yml
bc_config = nil
config_file_path = File.join(... | Ruby |
# BrokenCompass
INDEX_DIRECTORY = "broken_compass"
DEFAULT_COLUMN_WEIGHT = 10
module ActiveRecord #:nodoc:
class Base
#look_in_brokencompass method
def self.look_in_brokencompass(searchTerm = nil, options ={})
t1 = Time.now
brokencompass_option = options
brokencompass_option ||= {}
... | Ruby |
require 'rubygems'
require 'active_support'
require 'active_support/test_case' | Ruby |
puts "Adding BrokenCompass Version: 1.0"
require "startup"
require "broken_compass"
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the broken_compass plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for ... | Ruby |
require "rubygems"
require "activerecord"
namespace :brokencompass do
desc "Creates indexes"
task :index do
brokencompass_logger ||= Logger.new("#{RAILS_ROOT}/log/brokencompass.log")
brokencompass_logger.info("Starting index creation at #{Time.now}")
if File.exist?(File.join(RAILS_ROOT,"config","bro... | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module ActiveRecord #:nodoc:
class Base
@@bc_logger ||= Logger.new("#{RAILS_ROOT}/log/brokencompass.log")
#Initializing index container if not already initialized
@@broken_compass_index ||= {}
#Loading configurations from config/brokencompass.yml
bc_config = nil
config_file_path = File.join(... | Ruby |
# BrokenCompass
INDEX_DIRECTORY = "broken_compass"
DEFAULT_COLUMN_WEIGHT = 10
module ActiveRecord #:nodoc:
class Base
#look_in_brokencompass method
def self.look_in_brokencompass(searchTerm = nil, options ={})
t1 = Time.now
brokencompass_option = options
brokencompass_option ||= {}
... | Ruby |
require 'rubygems'
require 'active_support'
require 'active_support/test_case' | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
###########################
#Enumeracion de los Tokens#
###########################
#Creacion de un hash de las palabras claves
rw = Hash::new
reserved_words = %w(declare execute done read write while do if else then end for from at tape to true false integer boolean)
#Se van agregando iterativamente al hash con su re... | Ruby |
# -*- coding: utf-8 -*-
#SymTable
class SymTableError < RuntimeError; end
class RedefineError < SymTableError
def initialize(token, token_viejo)
@token = token
@token_viejo = token_viejo
end
def to_s
"Error en línea #{@token.line}, columna #{@token.column}: la variable '#{@token.text}' fue previamen... | Ruby |
#
# Hash para la ejecucion, guarda la variable con su valor
# ademas de atributo elastico(si se puede modificar)
class ValueTable
def initialize(padre = nil)
@padre = padre
@table = {}
end
def insert(variable)
@table[variable] = {:valor => nil, :elastico => true}
end
def update(variable, valor)... | Ruby |
# -*- coding: utf-8 -*-
class ContextError < RuntimeError
end
class ErrorDeTipo < ContextError
def initialize(linea, columna, operacion, tipo_izq, tipo_der)
@linea = linea
@columna = columna
@operacion = operacion
@tipo_izq = tipo_izq
@tipo_der = tipo_der
end
def to_s
"Error cerca de la ... | Ruby |
###########################
#Declaracion de las clases#
###########################
require_relative 'Tokens'
#Clase general para guardar un texto, linea y columna
class PhraseS
attr_accessor :text, :line, :column # Puede ser leido y escribir en ellos
def initialize(text, line, column)
@text = text
@line... | Ruby |
#AST
$as_tree = [
['AST', [], [
['Programa', %w[alcance], []] ,
['Alcance', %w[declaraciones secuenciacion], []],
['Declaracion', %w[lista tipo], []],
['Declaraciones', %w[lista_declaraciones], []],
... | Ruby |
module Brainiac end
require_relative 'AST2'
require_relative 'ContextErrors'
require_relative 'SymTable'
class TipoError; def self.name_tk; 'desconocido' end; end
#
#Redifinicion de las clases para anilisis de contexto
#
#
# Todos son redefinidas con un metodo check, que verifica
# los errores de contexto. Va recor... | Ruby |
require_relative 'Context'
require_relative 'DynamicErrors'
require_relative 'Execution'
class Programa
def exec
@attr_value[0][1].exec(ValueTable::new)
end
end
class Alcance
def exec(tabla)
unless @attr_value[0][1].class.eql? Array then
@attr_value[0][1].exec(tabla)
end
@attr_value[1]... | Ruby |
require_relative 'Classs'
#Clase fundamental que realiza el recorrido de la entrada
#Diferencia de los tokens y errores
#Para luego ser impresos en pantalla
class Lexer
#Inicializacion con la entrada como Stirng
def initialize(input)
@tokens = [] # Arreglo de tokens
@errors = [] #Arreglo de errores
@inp... | Ruby |
# -*- coding: utf-8 -*-
class DynamicError < RuntimeError
end
class LimetesInvalidos < DynamicError
def initialize(line, column)
@line = line
@column = column
end
def to_s
"Error entre la línea #{@line} y columna #{@column}: Los limites de la iteracion son inválido."
end
end
class CintaMalConstru... | Ruby |
#AST
#Representacion del AST para crear todos las clases necesarias
require_relative 'Meta'
$as_tree = [
['AST', [], [
['Programa', %w[alcance], []] ,
['Alcance', %w[declaraciones secuenciacion], []],
['Declaracion', %w[lista tipo]... | Ruby |
require_relative 'Context2'
require_relative 'DynamicErrors'
require_relative 'Execution'
#
# Redifinicion de las clases del AST con un metodo
# exec, para realizar la ejecucion.
# ....
#
class Programa
def exec
@alcance.exec(ValueTable::new)
end
end
class Alcance
def exec(tabla)
unless @declaraci... | Ruby |
#!/usr/bin/env ruby
#################################
#Definicion del Main de Brainiac#
#################################
require_relative 'Lexer'
require_relative 'Parser'
def to_s_recursive(ast,prof)
if !ast.class.eql?Array
ast.attr_value.each do |name|
if !(name[0] =~ /\A.*\./)
if name[1].cla... | Ruby |
module Brainiac end
require_relative 'AST'
require_relative 'ContextErrors'
require_relative 'SymTable'
class TipoError; def self.name_tk; 'desconocido' end; end
#
#Redifinicion de las clases para anilisis de contexto
#
class AST
attr_reader :line, :column, :type
def set_line(l)
@line = l
self
end
... | Ruby |
module Meta
def Meta::create_class(father, name, attr)
#1
nc = Class::new(father) do
#2
class << self
attr_reader :attr
end
#3
if !father.eql?Object
@attr = attr + father.attr
else
@attr = attr
end
#4
self.attr.each { |a|
... | Ruby |
source :gemcutter
gem 'jasmine'
gem 'rake'
gem 'jshintrb'
gem 'json'
| Ruby |
module Jasmine
class Config
# Add your overrides or custom config code here
end
end
# Note - this is necessary for rspec2, which has removed the backtrace
module Jasmine
class SpecBuilder
def declare_spec(parent, spec)
me = self
example_name = spec["name"]
@spec_ids << spec["id"]
... | Ruby |
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
require 'rubygems'
require 'jasmine'
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
if Jasmine::Depend... | Ruby |
require 'bundler'
Bundler.setup
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
def red(message)
"\e[31m#{message}\e[0m"
end
def green(message)
"\e[32m#{message}\e[0m"
end
desc "Run Jasmine unit tests under node.js"
task :node do
base = File.dirname(__FILE__)
if system("NODE_PATH=$NODE_PATH:#{base} " ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'data_mapper', '~> 1.2'
gem 'dm-postgres-adapter'
gem 'google-api-client', '>= 0.4.3'
group :development do
gem 'dm-sqlite-adapter', '~> 1.2'
gem 'do_sqlite3', '~> 0.10'
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.