Sha256: 12387cafd2a3b47b34cb2bc536b70c843502953208baf959e4003bb6368c2903
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
#! env ruby # # Interactive CQL command-line. # Copyright (c) 2007 Clifford Heath. Read the LICENSE file. # require 'activefacts' require 'activefacts/cql/parser' require 'readline' puts "This is a stub for the CQL interactive commandline. At the moment it only parses CQL and shows the parse trees." parser = ActiveFacts::CQLParser.new parser.root = :definition statement = nil while line = Readline::readline(statement ? "CQL+ " : "CQL? ", []) statement = statement ? statement + "\n"+line : line if line =~ %r{\A/} # meta-commands start with / case (words = line.split).shift when "/root" parser.root = words[0] && words[0].to_sym || :definition puts "ok" else puts "Unknown metacommand #{line}, did you mean /root <rule>?" end statement = nil elsif parser.root != :definition or line.gsub(/(['"])([^\1\\]|\\.)*\1/,'') =~ /;/ # After stripping string literals the line contains a ';', it's the last line of the command: begin result = parser.parse(statement) if result begin p result.value rescue => e puts e.to_s+":" p result # In case the root is changed and there's no value() end #p parser.definition(result) else p parser.failure_reason end rescue => e puts e puts "\t"+e.backtrace*"\n\t" end statement = nil end end puts
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activefacts-0.6.0 | bin/cql |
activefacts-0.7.0 | bin/cql |