wmsybasesyn.msg

来自「著名的Handle」· MSG 代码 · 共 831 行

MSG
831
字号
{Grammar for a Sybase SQL HighLighter}
{Copyright 1999 Willo van der Merwe.  All right reserved}
{mailto:willo@wack.co.za}
{No syntax check takes Place}
{ DISCLAIMER:  This is provided as is, expressly without a warranty of any kind.}
{ You use it at your own risk. }

TwmSybSQLSyn {first Identifier is considered to be the Class Name }
tk        {second Identifier is considered to be the Identifier Prefix }
{Sensitive : Optional}
IdentStart '_', 'a'..'z', 'A'..'Z':: '_', '0'..'9', 'a'..'z', 'A'..'Z'::

KEYS  { all between KEYS and |><| is considered to be a keyword }
add
all
alter
and
any
arith_overflow
as
asc
at
authorization
avg
begin
between
break
browse
bulk
by
cascade
case
char_convert
check
checkpoint
close
clustered
coalesce
commit
compute
confirm
connect
constraint
continue
controlrow
convert
count
create
current
cursor
database
dbcc
deallocate
declare
default
delete
desc
dis
distinct
double
drop
dummy
dump
else
end
endtran
errlvl
errordata
errorexit
escape
except
exclusive
exec
execute
exists
exit
exp_row_size
external
fetch
fillfactor
for
foreign
from
goto
grant
group
having
holdlock
identity
identity_gap
identity_insert
identity_start
if
in
index
insert
install
intersect
into
is
isolation
jar
join
key
kill
level
like
lineno
load
lock
max
max_rows_per_page
min
mirror
mirrorexit
modify
national
noholdlock
nonclustered
not
null
nullif
numeric_truncation
of
off
offsets
on
once
online
only
open
option
or
order
over
partition
perm
permanent
plan
precision
prepare
primary
print
privileges
proc
procedure
processexit
proxy_table
public
quiesce
raiserror
read
readpast
readtext
reconfigure
reference
remove
reorg
replace
replication
reservepagegap
return
revoke
role
rollback
rowcount
rows
rule
save
schema
select
set
setuser
shared
shutdown
some
statistics
stripe
sum
syb_identity
syb_restree
table
temp
temporary
textsize
to
tran
transaction
trigger
truncate
tsequal
union
unique
unpartition
update
use
user
user_option
using
values
varying
view
waitfor
when
where
while
with
work
writetext
           {SQL-92}
absolute
action
allocate
are
assertion
bit
bit_length
both
cascaded
case
cast
catalog
char
char_length
character
character_length
coalesce
collate
collation
column
connection
constraints
corresponding
cross
current_date
current_time
current_timestamp
current_user
date
day
dec
decimal
deferrable
deferred
describe
descriptor
diagnostics
disconnect
domain
en
exec
exception
extract
false
first
float
found
full
get
global
go
hour
immediate
indicator
initially
inner
input
insensitive
int
integer
interval
join
language
last
leading
left
local
lower
match
minute
module
month
names
natural
nchar
next
no
nullif
numeric
octet_length
outer
output
overlaps
pad
partial
position
preserve
prior
real
relative
restrict
right
scroll
second
section
session_user
size
smallint
space
sql
sqlcode
sqlerror
sqlstate
substring
system_user
then
time
timestamp
timezone_hour
timezone_minute
trailing
translate
translation
trim
true
unknown
upper
usage
value
varchar
when
whenever
write
year
zone
     {Potential SQL92 Reserved Words}
after
alias
async
before
boolean
breadth
call
completion
cycle
data
depth
dictionary
each
elseif
equals
general
ignore
leave
less
limit
loop
modify
new
none
object
oid
old
operation
operators
others
parameters
pendant
preorder
private
protected
recursive
ref
referencing
resignal
return
returns
routine
row
savepoint
search
sensitive
sequence
signal
similar
sqlexception
structure
test
there
type
under
variable
virtual
visible
wait
without
|><| { token names }
Key
Comment
Identifier
Variable
Number
Space
String
Symbol
InvalidSymbol
Null
Unknown
|><|

CHARS

#0:: Null
BeginProc
  fTokenID := tkNull;
EndProc

#10:: LF
BeginProc
  fTokenID := tkSpace;
  inc(Run);
EndProc

#13:: CR
BeginProc
  fTokenID := tkSpace;
  Case FLine[Run + 1] of
    #10: inc(Run, 2);
  else inc(Run);
  end;
EndProc

#1..#9, #11, #12, #14..#32:: Space
BeginProc
  inc(Run);
  fTokenID := tkSpace;
  while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run);
EndProc

#34::  String
BeginProc
  fTokenID := tkString;
  repeat
    case FLine[Run] of
      #0, #10, #13: break;
      #92:                             {backslash}
        {if we have an escaped quote it doesn't count}
        if FLine[Run + 1] = #34 then inc(Run);
    end;
    inc(Run);
  until FLine[Run] = #34;
  if FLine[Run] <> #0 then inc(Run);
EndProc

#39::  AsciiChar
BeginProc
  fTokenID := tkString;
  repeat
    case FLine[Run] of
      #0, #10, #13: break;
    end;
    inc(Run);
  until FLine[Run] = #39;
  if FLine[Run] <> #0 then inc(Run);
EndProc

'0'..'9':: Number
BeginProc
  inc(Run);
  fTokenID := tkNumber;
  while FLine[Run] in
      ['0'..'9', '.', '-'] do
  begin
    case FLine[Run] of
      '.':
        if FLine[Run + 1] = '.' then break;
    end;
    inc(Run);
  end;
EndProc

'A'..'Z', 'a'..'z', '_':: Ident
BeginProc
  fTokenID := IdentKind((fLine + Run));
  inc(Run, fStringLen);
  while Identifiers[fLine[Run]] do inc(Run);
EndProc

'@':: Variable
BeginProc
  fTokenID := tkVariable;
  inc(Run, fStringLen);
  while Identifiers[fLine[Run]] do inc(Run);
EndProc

'!':: NotSymbol
BeginProc
  case FLine[Run + 1] of
    '=':                               {not equal}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {logical complement}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'{':: BraceOpen
BeginProc
  inc(Run);
  fTokenId := tkSymbol;
EndProc

'}':: BraceClose
BeginProc
  inc(Run);
  fTokenId := tkSymbol;
EndProc

'~':: Tilde
BeginProc
  inc(Run);                            {bitwise complement}
  fTokenId := tkSymbol;
EndProc

'|':: OrSymbol
BeginProc
  case FLine[Run + 1] of
    '=':                               {inclusive or assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '|':                               {conditional or}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {inclusive or}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'%':: RemainderSymbol
BeginProc
  case FLine[Run + 1] of
    '=':                               {remainder assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {remainder}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'&':: AndSymbol
BeginProc
  case FLine[Run + 1] of
    '=':                               {and assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '&':                               {conditional and}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {and}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'(':: RoundOpen
BeginProc
  inc(Run);
  FTokenID := tkSymbol;
  inc(FRoundCount);
EndProc

')':: RoundClose
BeginProc
  inc(Run);
  fTokenID := tkSymbol;
  dec(FRoundCount);
EndProc

'*':: Multiply
BeginProc
  case FLine[Run + 1] of
    '=':                               {multiply assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {multiply}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'+':: Plus
BeginProc
  case FLine[Run + 1] of
    '=':                               {add assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '+':                               {increment}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {add}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

',':: Comma
BeginProc
  inc(Run);
  fTokenID := tkSybmol;
EndProc

'-':: Minus
BeginProc
  case FLine[Run + 1] of
    '-':                               {comment}
      begin
        repeat
          inc(Run);
        until FLine[Run] in [#0, #10, #13];
        fTokenID := tkComment;
      end;
  else                                 {subtract}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'.':: Point
BeginProc
  inc(Run);                            {point}
  fTokenID := tkSymbol;
EndProc

'/':: Slash
BeginProc
  case FLine[Run + 1] of
    '*':
      begin
        fRange := rsComment;
        inc(Run);
        if fLine[Run+1] = '*' then     {documentation comment}
        begin
          fTokenID := tkDocument;
          inc(Run);
        end
        else                           {c style comment}
          fTokenID := tkComment;

        inc(Run);
        while fLine[Run] <> #0 do
          case fLine[Run] of
            '*':
              if fLine[Run + 1] = '/' then
              begin
                fRange := rsUnKnown;
                inc(Run, 2);
                break;
              end else inc(Run);
            #10: break;
            #13: break;
          else inc(Run);
          end;
      end;
    '=':                               {division assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {division}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

':':: Colon
BeginProc
  inc(Run);                            {colon - conditional}
  fTokenID := tkSymbol;
EndProc

';':: SemiColon
BeginProc
  inc(Run);                            {semicolon}
  fTokenID := tkSymbol;
EndProc

'<':: Lower
BeginProc
  case FLine[Run + 1] of
    '=':                               {less than or equal to}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '<':
      begin
        if FLine[Run + 2] = '=' then   {shift left assign}
        begin
          inc(Run, 3)
        end
        else                           {shift left}
        begin
          inc(Run, 2);
        end;
        fTokenID := tkSymbol;
      end;
  else                                 {less than}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'=':: Equal
BeginProc
  case FLine[Run + 1] of
    '=':                               {logical equal}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '>':                               {Hash operator}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {assign}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'>':: Greater
BeginProc
  Case FLine[Run + 1] of
    '=':                               {greater than or equal to}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
    '>':
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {greater than}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc

'?':: Question
BeginProc
  fTokenID := tkSymbol;                {question mark - conditional}
  inc(Run);
EndProc

'[':: SquareOpen
BeginProc
  inc(Run);
  fTokenID := tkSymbol;
  inc(FSquareCount);
EndProc

']':: SquareClose
BeginProc
  inc(Run);
  fTokenID := tkSymbol;
  dec(FSquareCount);
EndProc

'^':: XOrSymbol
BeginProc
  Case FLine[Run + 1] of
    '=':                               {xor assign}
      begin
        inc(Run, 2);
        fTokenID := tkSymbol;
      end;
  else                                 {xor}
    begin
      inc(Run);
      fTokenID := tkSymbol;
    end;
  end;
EndProc
|><|

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?