Sha256: c3a006f99a61d3d10812fbe103334a2a4e5eccd824dc373e6d8c3d00b7283646
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
#! env ruby # # ActiveFacts: Interactive CQL command-line. Incomplete; only parses CQL and shows the parse trees # # Copyright (c) 2009 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activefacts-0.7.1 | bin/cql |
activefacts-0.7.2 | bin/cql |
activefacts-0.7.3 | bin/cql |