Method: CLI#lex

Defined in:
lib/crossplane/cli.rb

#lex(filename) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/crossplane/cli.rb', line 114

def lex(filename)
	payload = CrossPlane::Lexer.new(
		filename: filename,
	).lex()
	lex = (not options['line_numbers'].nil? and options['line_numbers'] == true) ? payload : payload.map{|e| e[0]}

	if options['out']
		File.open(options['out'], 'w') do |f|
			f.write(JSON.pretty_generate(lex))
		end
	else
		puts options['pretty'] ? JSON.pretty_generate(lex) : lex.to_json
	end
end