Class: Vertigo::Compiler
- Inherits:
-
Object
- Object
- Vertigo::Compiler
- Defined in:
- lib/vertigo/compiler.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
Returns the value of attribute ast.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #compile(filename) ⇒ Object
- #dump_ast ⇒ Object
- #gen_tb(filename) ⇒ Object
-
#initialize(options = {}) ⇒ Compiler
constructor
A new instance of Compiler.
- #parse(filename) ⇒ Object
- #pretty_print ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Compiler
Returns a new instance of Compiler.
14 15 16 |
# File 'lib/vertigo/compiler.rb', line 14 def initialize ={} @options= end |
Instance Attribute Details
#ast ⇒ Object
Returns the value of attribute ast.
12 13 14 |
# File 'lib/vertigo/compiler.rb', line 12 def ast @ast end |
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/vertigo/compiler.rb', line 11 def @options end |
Instance Method Details
#compile(filename) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vertigo/compiler.rb', line 18 def compile filename begin parse(filename) puts "=> parsed successfully. Good" unless [:mute] dump_ast if [:dump_ast] pretty_print if [:pp] or [:pp_to_file] return true rescue Exception => e puts e.backtrace unless [:mute] puts e unless [:mute] raise end end |
#dump_ast ⇒ Object
38 39 40 |
# File 'lib/vertigo/compiler.rb', line 38 def dump_ast pp @ast end |
#gen_tb(filename) ⇒ Object
56 57 58 59 |
# File 'lib/vertigo/compiler.rb', line 56 def gen_tb filename parse filename TestBenchGenerator.new().generate_from(ast) end |
#parse(filename) ⇒ Object
32 33 34 35 36 |
# File 'lib/vertigo/compiler.rb', line 32 def parse filename puts "=> parsing VHDL file : #{filename}" unless [:mute] @basename=File.basename(filename,File.extname(filename)) @ast=Parser.new().parse filename end |
#pretty_print ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vertigo/compiler.rb', line 42 def pretty_print puts "=> pretty printing" unless [:mute] begin code=PrettyPrinter.new.print(ast) file=code.save_as "#{@basename}_pp.vhd" if [:pp_to_file] puts " - saved as #{file}" if [:pp_to_file] unless [:mute] puts code.finalize if [:pp] rescue Exception => e puts e.backtrace if [:pp] puts e if [:pp] raise "pp error" end end |