Class: Sweet

Inherits:
Object
  • Object
show all
Defined in:
lib/sweet.rb

Instance Method Summary collapse

Instance Method Details

#parsing_optionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sweet.rb', line 10

def parsing_options

  opts = Trollop::options do
    version "Sweet 0.3.7 (c) 2012 Joao Moura a.k.a D3TR1"
    banner <<-EOS
    A Sweet Language, that compiles for HTML.

    Usage:
         sweet [options] <filename> or <path>

    Examples:
         sweet -c example.s
         sweet -w ./
         sweet -o

    Options:
    EOS

    opt :compile, "Compile a single file", :type => :string
    opt :watch, "Watch a directory", :type => :string
    opt :console, "Open SIC ( Sweet Interactive Console )"
  end
  Trollop::die :compile, "the file must exist" unless File.exist?(opts[:compile]) if opts[:compile]
  return opts

end

#sicObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sweet.rb', line 37

def sic

  puts "Sweet Interactive Console, CTRL+C to quit"
  loop do
    line = Readline::readline(">> ")
    Readline::HISTORY.push(line)
    value = interpreter.eval(line)
    puts "=> #{value.ruby_value.inspect}"
  end

end