Class: Pione::Command::PioneSyntaxChecker
Overview
PioneSyntaxChecker is a command for checking syntax tree and model of the PIONE document.
Instance Attribute Summary
Attributes inherited from BasicCommand
#option, #running_thread
Instance Method Summary
collapse
#abort, command_banner, command_front, command_name, #enter_phase, execute, #execution?, execution_phase, #exit, handle_exception, handle_execution_exception, handle_setup_exception, handle_termination_exception, inherited, init, #init?, init_phase, option_parser_mode, #run, run, setup, #setup?, setup_phase, #terminate, terminate, #termination?, termination_phase
Constructor Details
68
69
70
71
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 68
def initialize(*argv)
super
@history = File.join(Global.dot_pione_dir, "pione-history")
end
|
Instance Method Details
#execute_expr ⇒ Object
129
130
131
132
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 129
def execute_expr
parser_name = option[:parser] ? option[:parser] : :expr
print_result(DocumentParser.new.send(parser_name), option[:expr])
end
|
#execute_file ⇒ Object
125
126
127
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 125
def execute_file
print_result(DocumentParser.new, Pathname.new(option[:document]).read)
end
|
#execute_readline_mode ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 97
def execute_readline_mode
buf = ""
mark = ">"
while buf += Readline.readline("#{mark} ".color(:red), true)
if /[^\s]/.match(buf)
if Readline::HISTORY.size > 1 && Readline::HISTORY[-2] == buf
Readline::HISTORY.pop
end
if buf[-1] == "\\"
buf[-1] = "\n"
mark = "+"
next
else
print_result(DocumentParser.new.expr, buf)
buf = ""
mark = ">"
end
else
Readline::HISTORY.pop
end
end
end
|
#setup_pp ⇒ Object
80
81
82
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 80
def setup_pp
require 'pp'
end
|
#setup_readline_mode ⇒ Object
84
85
86
87
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 84
def setup_readline_mode
require 'readline'
restore_history
end
|
#terminate_history ⇒ Object
140
141
142
|
# File 'lib/pione/command/pione-syntax-checker.rb', line 140
def terminate_history
save_history if readline_mode?
end
|