gnn-ruby-code-study / scripts /check_syntax.rb
timlawrenz's picture
Upload scripts/check_syntax.rb with huggingface_hub
0e0540e verified
raw
history blame contribute delete
290 Bytes
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'parser/current'
# Reads code from stdin and exits with 0 if syntax is valid, 1 otherwise.
begin
code = $stdin.read
Parser::CurrentRuby.parse(code)
exit 0
rescue Parser::SyntaxError => e
$stderr.puts e.message
exit 1
end