Class: Rattler::Runner
- Inherits:
-
Object
- Object
- Rattler::Runner
- Defined in:
- lib/rattler/runner.rb
Overview
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.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rattler/runner.rb', line 35 def initialize(args) @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
28 29 30 |
# File 'lib/rattler/runner.rb', line 28 def self.run(args) self.new(args).run end |
Instance Method Details
#run ⇒ Object
Run the command-line parser.
47 48 49 50 51 52 53 54 |
# File 'lib/rattler/runner.rb', line 47 def run if result = analyze synthesize(result) else puts parser.failure exit ERRNO_PARSE_ERROR end end |