lib/lrama/option_parser.rb in lrama-0.6.11 vs lib/lrama/option_parser.rb in lrama-0.7.0
- old
+ new
@@ -57,12 +57,12 @@
o.separator 'STDIN mode:'
o.separator 'lrama [options] - FILE read grammar from STDIN'
o.separator ''
o.separator 'Tuning the Parser:'
o.on('-S', '--skeleton=FILE', 'specify the skeleton to use') {|v| @options.skeleton = v }
- o.on('-t', 'reserved, do nothing') { }
- o.on('--debug', 'display debugging outputs of internal parser') {|v| @options.debug = true }
+ o.on('-t', '--debug', 'display debugging outputs of internal parser') {|v| @options.debug = true }
+ o.on('-D', '--define=NAME[=VALUE]', Array, "similar to '%define NAME VALUE'") {|v| @options.define = v }
o.separator ''
o.separator 'Output:'
o.on('-H', '--header=[FILE]', 'also produce a header file named FILE') {|v| @options.header = true; @options.header_file = v }
o.on('-d', 'also produce a header file') { @options.header = true }
o.on('-r', '--report=REPORTS', Array, 'also produce details on the automaton') {|v| @report = v }
@@ -84,10 +84,11 @@
o.on_tail ''
o.on_tail 'TRACES is a list of comma-separated words that can include:'
o.on_tail ' automaton display states'
o.on_tail ' closure display states'
o.on_tail ' rules display grammar rules'
+ o.on_tail ' only-explicit-rules display only explicit grammar rules'
o.on_tail ' actions display grammar rules with actions'
o.on_tail ' time display generation time'
o.on_tail ' all include all the above traces'
o.on_tail ' none disable all traces'
o.on('-v', '--verbose', "same as '--report=state'") {|_v| @report << 'states' }
@@ -134,29 +135,30 @@
(ALIASED_REPORTS[opt.to_sym] || opt).to_sym
end
VALID_TRACES = %w[
locations scan parse automaton bitsets closure
- grammar rules actions resource sets muscles
- tools m4-early m4 skeleton time ielr cex
+ grammar rules only-explicit-rules actions resource
+ sets muscles tools m4-early m4 skeleton time ielr cex
].freeze
NOT_SUPPORTED_TRACES = %w[
locations scan parse bitsets grammar resource
sets muscles tools m4-early m4 skeleton ielr cex
].freeze
+ SUPPORTED_TRACES = VALID_TRACES - NOT_SUPPORTED_TRACES
def validate_trace(trace)
h = {}
return h if trace.empty? || trace == ['none']
- supported = VALID_TRACES - NOT_SUPPORTED_TRACES
+ all_traces = SUPPORTED_TRACES - %w[only-explicit-rules]
if trace == ['all']
- supported.each { |t| h[t.to_sym] = true }
+ all_traces.each { |t| h[t.gsub(/-/, '_').to_sym] = true }
return h
end
trace.each do |t|
- if supported.include?(t)
- h[t.to_sym] = true
+ if SUPPORTED_TRACES.include?(t)
+ h[t.gsub(/-/, '_').to_sym] = true
else
raise "Invalid trace option \"#{t}\"."
end
end