mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
recode heuristic to use existing style. add additional sample
This commit is contained in:
@@ -224,29 +224,22 @@ module Linguist
|
||||
end
|
||||
end
|
||||
disambiguate "PLSQL", "SQLPL", "PLpgSQL", "SQL" do |data|
|
||||
match = nil
|
||||
#unique keywords for each language
|
||||
plpgsqlkeywords = [/^\\i\b/i, /begin ?(work|transaction)?;/i , /AS \$\$/i, /RAISE EXCEPTION/i, /LANGUAGE plpgsql\b/i ]
|
||||
plsqlkeywords = [ /pragma\b/i , /constructor\W+function\b/i]
|
||||
#sqlplkeywords = [ ]
|
||||
#only return value if a definite positive
|
||||
|
||||
#common keywords that are not SQL
|
||||
plkeywords = [/begin\b/i,/boolean\b/i, /package\b/i,/exception\b/i, /^end;\b/i ]
|
||||
|
||||
re = Regexp.union(plpgsqlkeywords)
|
||||
if data.match(re)
|
||||
match = Language["PLpgSQL"]
|
||||
else
|
||||
re = Regexp.union(plsqlkeywords)
|
||||
if data.match(re)
|
||||
match= Language["PLSQL"]
|
||||
else
|
||||
re = Regexp.union(plkeywords)
|
||||
match= Language["SQL"] if ! data.match(re)
|
||||
end
|
||||
if /^\\i\b|AS \$\$|LANGUAGE '+plpgsql'+/i.match(data) || /SECURITY (DEFINER|INVOKER)/i.match(data) || /BEGIN (WORK|TRANSACTION)+;/i.match(data)
|
||||
#postgres
|
||||
Language["PLpgSQL"]
|
||||
elsif /(alter module)|(language sql)|(begin( NOT)+ atomic)/i.match(data) || /signal SQLSTATE '[0-9]+'/i.match(data)
|
||||
#ibm db2
|
||||
Language["SQLPL"]
|
||||
elsif /pragma|\$\$PLSQL_|XMLTYPE|sysdate|systimestamp|\.nextval|connect by|AUTHID (DEFINER|CURRENT_USER)/i.match(data) || /constructor\W+function/i.match(data)
|
||||
#oraclestuff
|
||||
Language["PLSQL"]
|
||||
elsif ! /begin|boolean|package|exception/i.match(data)
|
||||
#generic sql
|
||||
Language["SQL"]
|
||||
end
|
||||
|
||||
match
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2696,13 +2696,13 @@ SQL:
|
||||
- .viw
|
||||
|
||||
#IBM DB2
|
||||
#SQLPL:
|
||||
#type: programming
|
||||
#ace_mode: sql
|
||||
#tm_scope: source.sql
|
||||
#extensions:
|
||||
#- .sql
|
||||
#- .db2
|
||||
SQLPL:
|
||||
type: programming
|
||||
ace_mode: sql
|
||||
tm_scope: source.sql
|
||||
extensions:
|
||||
- .sql
|
||||
- .db2
|
||||
|
||||
STON:
|
||||
type: data
|
||||
|
||||
9
samples/SQLPL/sleep.sql
Normal file
9
samples/SQLPL/sleep.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
create procedure sleep (in sleeptime integer)
|
||||
begin
|
||||
declare wait_until timestamp;
|
||||
|
||||
set wait_until = (current timestamp + sleeptime seconds);
|
||||
while (wait_until > current timestamp)
|
||||
do
|
||||
end while;
|
||||
end!
|
||||
Reference in New Issue
Block a user