Way cool ! Just when I wanted something similar ;-)

Will I be able to take some of your regexes to quasi-parse my SQL ?
See code fragment below (culled from dbtalk.rb).

Thanks a lot for a timely (for me) release...

-- Shanko

#----------------------

  # Regular expression for the complete SQL query (hopefully covers 99.9% of
cases)
  SQLCMD =
/(--.*$|[^-;'"]+|-|'(\\'|[^'])*('|\z)|"(\\"|[^"])*("|\z))*(;|\z)(--.*|[ ]+)*
/

  # SQL keywords and their color styles
  KEYWCOLS = {
    'explain' => 1, 'select' => 1, 'distinct' => 2, 'from' => 2, 'where' =>
2,
     ... # code
     ... # snip
    'by' => 2
  }  # 'by' is added because 'group by' doesn't work, I think it should

  # Sanitize the hash and put SQL keywords in the array
  KEYWORDS = KEYWCOLS.delete_if { | key, val| !(1..3).include?(val) }.keys

# Construct the reqular expression for SQL literals, comments and literals
regexpsrc = %q!^' |'$|'(\\\'|[^'])*('|\z)|"(\\\"|[^"])*("|\z)|\b\d+\b|--.*$!
#''JFF'

KEYWORDS.each { |keyword| regexpsrc += '|\b' + keyword + '\b' }
@shregexp = Regexp.new(regexpsrc, Regexp::IGNORECASE)

buf = " SELECT 'By Accts' MSG,ACCT , COUNT(*), MAX(billing_dt), MIN(rate)
\n"  +
         " INTO tbl1 -- temp table \n" +
         " FROM CUST_ACT \n WHERE acct_nbr IS NULL \n" +
         " GROUP BY ACCT \n HAVING COUNT(*) > 1;"

i   = 0
# While a pattern is found
while m = @shregexp.match(buf)

  puts m.to_s

  # decide and set the right style
  if m[0][0] == 34 or m[0][0] == 39 or m[0][0].between?(48,57)  # ' " 0-9
    s = 1
  elsif m[0][0] == 45  # -- SQL comment
    s = 2
  else
    s = KEYWCOLS[m[0].downcase] + 2  # SQL keyword has defined style
  end

  #puts(i, m.begin(0), 0) if m.begin(0) > 0       # normal style
  #puts(i + m.begin(0), m.end(0)- m.begin(0), s)  # highlight

  # Move on in the buffer
  i += m.end(0)
  buf = m.post_match

end

# The rest of the buffer is normal
#puts(i, buf.length, 0) if buf.length > 0  # normal

#----------------------


"Dalibor Sramek" <dali / epot.cz> wrote in message
news:20020913175024.A57815 / epot.cz...
> I would like to announce a new release of my Ruby project DbTalk.
> The project page can be found at http://www.insula.cz/dbtalk/ (changed
URL!).
>
> DbTalk is an interactive GUI based tool for database querying,
programming,
> administration etc. It consists of three basic parts:
> - SQL editor
> - query result viewer
> - database structure viewer
>
> Important features of DbTalk are:
> - ODBC support (UNIX, Windows)
> - direct support for MySQL (UNIX, Windows), and PostgreSQL (UNIX)
> - multiple database connections (also multiple servers and databases)
> - easy editing and testing of multiline SQL commands (e.g. procedure
> definitions) with syntax highlighting and text completion
> - created SQL commands can be saved into a file and used later
> - nice tabular view of selected data
> - tree view of the database structure
> - DbTalk is free under the terms of GPL
>
> The current version of DbTalk is 0.7. Compared to the 0.6 version DbTalk
now
> features:
> - SQL syntax highlighting
> - text completion (SQL keywords and database elements)
> - pasting from result table (not perfect however because the Fox table
> widget does not support clipboard)
> - last but not least - lot of bugs is fixed
>
> Compared to the 0.5 version DbTalk now features:
> - ODBC support
> - connection profiles
> - improved table browser
> - possibility to run scripts
> - font configuration
> - greatly improved stability
>
> It is recommended to install a recent version of Fox and FXRuby. DbTalk
0.7
> was successfully tested with FXRuby 1.0.13, Fox 1.0.3 and 1.0.18.
> The FXRuby version older than 1.0.3 contained bug that made DbTalk to
crash
> from time to time.
>