zxbasic.vim

Priskribo de la ĉi-paĝa enhavo

Sintaksa dosiero pri ZX BASIC por la redaktilo Vim.

Mi verkis la suban Vim-sintaksan dosieron por pli komforte programi en ZX BASIC per mia plej ŝatata redaktilo. Komence mi prenis la samcelan FreeBASIC-dosieron kiun la programo jam inkludis, por ĝin modifi (ambaj lingvoj multe similas).

La dosiero ne finitas, sed plimultaj kutimaj ŝlosil-vortoj kaj operaci-simboloj jam estas ĝuste kolorigitaj. Kiam ĝi finitas, mi ĝin proponos por inkludo en ontan Vim-version.

Printaĵo


" zxbasic.vim
" Vim syntax file
" Language:   ZX BASIC (http://www.zxbasic.net)
" Maintainer: Marcos Cruz (http://programandala.net)
" URL:        http://programandala.net
" Updated:    2010-07-06

" Note:

" This is a work in progress. The unfinished issues are marked with "!!!".

" History:

" 2010-04-18 First draft, based on the FreeBASIC version mantained by Mark Manning.
" 2010-07-06 Fixed: the aspect of the zxbasicLoops label was undefined.

" --------------------------------------------------------------

if exists("b:current_syntax")
 finish
endif

syn case ignore

syn keyword zxbasicBitManipulation SHL SHR >> <<

syn keyword zxbasicCompilerSwitches BYREF BYVAL

syn keyword zxbasicConditional IF ELSE ENDIF

syn keyword zxbasicConsole AT BOLD BORDER BRIGHT CLS FLASH INK INVERSE ITALIC OVER PAPER POS PRINT TAB

syn keyword zxbasicDataTypes AS DIM BYTE CONST INTEGER LONG STRING UBYTE UINTEGER ULONG 

syn keyword zxbasicDebug STOP

" syn keyword zxbasicFiles CODE LOAD SAVE SCREEN$ VERIFY

syn keyword zxbasicFunctions FUNCTION SUB 

syn keyword zxbasicGraphics CIRCLE DRAW PLOT POINT SCREEN SCREEN$

syn keyword zxbasicHardware BEEP IN OUT 

syn keyword zxbasicLogical AND NOT OR

syn keyword zxbasicMath ABS ACS ASN ATN COS EXP INT LEN LN MOD PI RANDOMIZE RND SGN SIN SQR TAN VAL

syn keyword zxbasicMemory CLEAR PEEK POKE 

syn keyword zxbasicMisc ASM LET TO FASTCALL STDCALL

syn keyword zxbasicLoops FOR LOOP WHILE WEND DO CONTINUE STEP UNTIL NEXT

" !!! unfinished
syn match zxbasicInclude "\<#\s*\(inclib\|include\)\>"
syn match zxbasicInclude "\<\$\s*include\>"

" !!! unfinished
"syn keyword zxbasicPredefined __DATE__ __FB_DOS__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__

" !!! unfinished
syn match zxbasicPreProcessor "\<^#\s*\(define\|undef\)\>"
syn match zxbasicPreProcessor "\<^#\s*\(ifdef\|ifndef\|else\|elseif\|endif\|if\)\>"

syn keyword zxbasicProgramFlow END EXIT GOSUB GOTO RETURN
" !!! how to do "go to" and "go sub"?:
syn match zxbasicProgramFlow "\<\s+\(GO TO|GO SUB\)\s+\>"

syn keyword zxbasicTypeCasting CAST 

syn keyword zxbasicUserInput INKEY INKEY$ PAUSE
syn keyword zxbasicUserInput INPUT

" Do the Basic variables names first. This is because it
" is the most inclusive of the tests. Later on we change
" this so the identifiers are split up into the various
" types of identifiers like functions, basic commands and
" such. MEM 9/9/2006

syn match zxbasicIdentifier "\<[a-zA-Z][a-zA-Z0-9]*\>"
syn match zxbasicGenericFunction "\<[a-zA-Z][a-zA-Z0-9]*\>\s*("me=e-1,he=e-1


" Catch errors caused by wrong parenthesis

syn region zxbasicParen transparent start='(' end=')' contains=ALLBUT,@zxbasicParenGroup
syn match zxbasicParenError ")"
syn match zxbasicInParen contained "[{}]"
syn cluster zxbasicParenGroup contains=zxbasicParenError,zxbasicSpecial,zxbasicTodo,zxbasicUserCont,zxbasicUserLabel,zxbasicBitField

" Integer number, or floating point number without a dot and with "f".

" !!!unfinished:
syn region zxbasicHex start="&h" end="\W"
syn region zxbasicHexError start="&h\x*[g-zG-Z]" end="\W"
syn match zxbasicInteger "\<\d\+\(u\=l\=\|lu\|f\)\>"

" Floating point number, with dot, optional exponent

" !!!unfinished:
syn match zxbasicFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"

" Floating point number, starting with a dot, optional exponent

" !!!unfinished:
syn match zxbasicFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"

" Floating point number, without dot, with exponent

" !!!unfinished:
syn match zxbasicFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"

" String and Character contstants

syn region zxbasicString start='"' end='"' contains=zxbasicSpecial,zxbasicTodo
syn region zxbasicString start="'" end="'" contains=zxbasicSpecial,zxbasicTodo
syn keyword zxbasicString CHR CHR$ STR STR$ 

" Comments

" !!!unfinished:
syn match zxbasicSpecial contained "\\."
syn keyword zxbasicTodo contained TODO
syn region zxbasicComment start="^rem" end="$" contains=zxbasicSpecial,zxbasicTodo
syn region zxbasicComment start=":\s*rem" end="$" contains=zxbasicSpecial,zxbasicTodo
syn region zxbasicComment start="\s*'" end="$" contains=zxbasicSpecial,zxbasicTodo
syn region zxbasicComment start="^'" end="$" contains=zxbasicSpecial,zxbasicTodo

" Labels and line numbers

" !!!unfinished:
syn match zxbasicLabel "^\d"
syn match zxbasicLabel "\<^\w+:\>"
syn region zxbasicLineNumber start="^\d" end="\s"

" Create the clusters

syn cluster zxbasicNumber contains=zxbasicHex,zxbasicInteger,zxbasicFloat
syn cluster zxbasicError contains=zxbasicHexError

" Math operators

" !!!unfinished:
syn match zxbasicMathOperator "[\+\-\=\|\*\/\>\<\%\()[\]]" contains=zxbasicParen

" The default methods for highlighting. Can be overridden later

hi def link zxbasicArrays StorageClass
hi def link zxbasicBitManipulation Operator
hi def link zxbasicCompilerSwitches PreCondit
hi def link zxbasicConsole Special
hi def link zxbasicDataTypes Type
hi def link zxbasicDateTime Type
hi def link zxbasicDebug Special
hi def link zxbasicErrorHandling Special
hi def link zxbasicFiles Special
hi def link zxbasicFunctions Function
hi def link zxbasicGraphics Function
hi def link zxbasicHardware Special
hi def link zxbasicLogical Conditional
hi def link zxbasicMath Function
hi def link zxbasicMemory Function
hi def link zxbasicMisc Special
hi def link zxbasicModularizing Special
hi def link zxbasicMultithreading Special
hi def link zxbasicShell Special
hi def link zxbasicEnviron Special
hi def link zxbasicPointer Special
hi def link zxbasicPredefined PreProc
hi def link zxbasicPreProcessor PreProc
hi def link zxbasicProgramFlow Statement
hi def link zxbasicLoops Statement
hi def link zxbasicString String
hi def link zxbasicTypeCasting Type
hi def link zxbasicUserInput Statement
hi def link zxbasicComment Comment
hi def link zxbasicConditional Conditional
hi def link zxbasicError Error
hi def link zxbasicIdentifier Identifier
hi def link zxbasicInclude Include
hi def link zxbasicGenericFunction Function
hi def link zxbasicLabel Label
hi def link zxbasicLineNumber Label
hi def link zxbasicMathOperator Operator
hi def link zxbasicNumber Number
hi def link zxbasicSpecial Special
hi def link zxbasicTodo Todo

let b:current_syntax = "zxbasic"

" vim: ts=4
" vim: set ignorecase
" vim: set smartcase

Deŝuto

Glosoj

BASIC
Beginner's All-Purpose Symbolic Instruction Code (ĉia-uza kodo de simbolaj instrukcioj por komencantoj)
Vim
Vi IMproved (plibonigita Vi)