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
|
||||||
end
|
end
|
||||||
disambiguate "PLSQL", "SQLPL", "PLpgSQL", "SQL" do |data|
|
disambiguate "PLSQL", "SQLPL", "PLpgSQL", "SQL" do |data|
|
||||||
match = nil
|
#only return value if a definite positive
|
||||||
#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 = [ ]
|
|
||||||
|
|
||||||
#common keywords that are not SQL
|
if /^\\i\b|AS \$\$|LANGUAGE '+plpgsql'+/i.match(data) || /SECURITY (DEFINER|INVOKER)/i.match(data) || /BEGIN (WORK|TRANSACTION)+;/i.match(data)
|
||||||
plkeywords = [/begin\b/i,/boolean\b/i, /package\b/i,/exception\b/i, /^end;\b/i ]
|
#postgres
|
||||||
|
Language["PLpgSQL"]
|
||||||
re = Regexp.union(plpgsqlkeywords)
|
elsif /(alter module)|(language sql)|(begin( NOT)+ atomic)/i.match(data) || /signal SQLSTATE '[0-9]+'/i.match(data)
|
||||||
if data.match(re)
|
#ibm db2
|
||||||
match = Language["PLpgSQL"]
|
Language["SQLPL"]
|
||||||
else
|
elsif /pragma|\$\$PLSQL_|XMLTYPE|sysdate|systimestamp|\.nextval|connect by|AUTHID (DEFINER|CURRENT_USER)/i.match(data) || /constructor\W+function/i.match(data)
|
||||||
re = Regexp.union(plsqlkeywords)
|
#oraclestuff
|
||||||
if data.match(re)
|
Language["PLSQL"]
|
||||||
match= Language["PLSQL"]
|
elsif ! /begin|boolean|package|exception/i.match(data)
|
||||||
else
|
#generic sql
|
||||||
re = Regexp.union(plkeywords)
|
Language["SQL"]
|
||||||
match= Language["SQL"] if ! data.match(re)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
match
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2696,13 +2696,13 @@ SQL:
|
|||||||
- .viw
|
- .viw
|
||||||
|
|
||||||
#IBM DB2
|
#IBM DB2
|
||||||
#SQLPL:
|
SQLPL:
|
||||||
#type: programming
|
type: programming
|
||||||
#ace_mode: sql
|
ace_mode: sql
|
||||||
#tm_scope: source.sql
|
tm_scope: source.sql
|
||||||
#extensions:
|
extensions:
|
||||||
#- .sql
|
- .sql
|
||||||
#- .db2
|
- .db2
|
||||||
|
|
||||||
STON:
|
STON:
|
||||||
type: data
|
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