Class: Rattler::Runner
- Inherits:
-
Object
- Object
- Rattler::Runner
- Defined in:
- lib/rattler/runner.rb
Overview
Rattler::Runner
defines the command-line parser generator.
Constant Summary collapse
- ERRNO_USAGE =
Invalid command line arguments
1
- ERRNO_READ_ERROR =
Error reading grammar file
2
- ERRNO_WRITE_ERROR =
Error writing parser file
3
- ERRNO_PARSE_ERROR =
Error parsing grammar
4
- ERRNO_GEN_ERROR =
Error generaing ruby code
5
Class Method Summary collapse
-
.run(args) ⇒ Object
Run the command-line parser.
Instance Method Summary collapse
-
#initialize(args) ⇒ Runner
constructor
Create a new command-line parser.
-
#run ⇒ Object
Run the command-line parser.
Constructor Details
#initialize(args) ⇒ Runner
Create a new command-line parser.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rattler/runner.rb', line 32 def initialize(args) @standalone = false @optimize = true .parse!(args) if args.size == 1 @srcfname = Pathname.new(args.shift) else puts exit ERRNO_USAGE end end |
Class Method Details
.run(args) ⇒ Object
Run the command-line parser
25 26 27 |
# File 'lib/rattler/runner.rb', line 25 def self.run(args) self.new(args).run end |
Instance Method Details
#run ⇒ Object
Run the command-line parser.
45 46 47 48 49 50 51 52 |
# File 'lib/rattler/runner.rb', line 45 def run if result = analyze synthesize(result) else puts parser.failure exit ERRNO_PARSE_ERROR end end |