1
###############################################################################
3
# Purpose: Define Forth syntax for highlighting and other features #
4
# Author: Cody Precord <cprecord@editra.org> #
5
# Copyright: (c) 2009 Cody Precord <staff@editra.org> #
6
# License: wxWindows License #
7
###############################################################################
12
@summary: Lexer configuration module for Forth
16
__author__ = "Cody Precord <cprecord@editra.org>"
17
__svnid__ = "$Id: _forth.py 63834 2010-04-03 06:04:33Z CJP $"
18
__revision__ = "$Revision: 63834 $"
20
#-----------------------------------------------------------------------------#
28
#-----------------------------------------------------------------------------#
30
#---- Keyword Definitions ----#
33
CONTROL_KW = (0, "again begin case do else endcase endof if loop of "
34
"repeat then until while [if] [else] [then] ?do")
37
KEYWORDS = (1, "dup drop rot swap over @ ! 2@ 2! 2dup 2drop 2swap 2over nip "
38
"r@ >r r> 2r@ 2>r 2r>; 0= 0<; sp@ sp! w@ w! c@ c! < > = "
39
"<> 0<> space spaces key? key throw catch abort */ 2* /mod "
40
"cell+ cells char+ chars move erase dabs title hex decimal "
41
"hold <# # #s #> sign d. . u. dump (.\") >number ' immediate "
42
"exit recurse unloop leave here allot , c, w, compile, branch, "
43
"ret, lit, dlit, ?branch, \", >mark >resolve1 <mark >resolve "
44
"align aligned user-allot user-here header does> smudge hide "
45
":noname last-word ?error error2 find1 sfind set-current "
46
"get-current definitions get-order forth only set-order also "
47
"previous voc-name. order latest literal 2literal sliteral "
48
"cliteral ?literal1 ?sliteral1 hex-literal hex-sliteral "
49
"?literal2 ?sliteral2 source EndOfChunk CharAddr PeekChar "
50
"IsDelimiter GetChar OnDelimiter SkipDelimiters OnNotDelimiter "
51
"SkipWord SkipUpTo ParseWord NextWord parse skip "
52
"console-handles refill depth ?stack ?comp word interpret bye "
53
"quit main1 evaluate include-file included >body +word "
54
"wordlist class! class@ par! par@ id. ?immediate ?voc "
55
"immediate VOC WordByAddrWl WordByAddr nlist words save options "
56
"/notransl ansi>oem accept emit cr type ekey? ekey ekey>char "
57
"externtask erase-imports ModuleName ModuleDirName environment? "
58
"drop-exc-handler set-exc-handler halt err close-file "
59
"create-file create-file-shared open-file-shared delete-file "
60
"file-position file-size open-file read-file reposition-file "
61
"dos-lines unix-lines read-line write-file resize-file "
62
"write-line allocate free resize start suspend resume stop "
63
"pause min max true false asciiz> r/o w/o ;class endwith or and "
64
"/string search compare export ;module space")
67
DEFINITION_KW = (2, "variable create : value constant vm: m: var dvar chars "
68
"obj constr: destr: class: object: pointer user "
69
"user-create user-value vect wndproc: vocabulary -- task: "
72
# Prewords with one argument
73
PREWORDS1 = (3, "CHAR [CHAR] POSTPONE WITH ['] TO [COMPILE] CHAR ASCII \\'")
75
# Prewords with two arguments
76
PREWORDS2 = (4, "REQUIRE WINAPI:")
78
# String definition Keywords
79
STRING_DEF_KW = (5, "S\" ABORT\" Z\" \" .\" C\"")
81
#---- End Keyword Definitions ----#
83
#---- Syntax Style Specs ----#
84
SYNTAX_ITEMS = [(stc.STC_FORTH_DEFAULT, "default_style"),
85
(stc.STC_FORTH_COMMENT, "comment_style"),
86
(stc.STC_FORTH_COMMENT_ML, "comment_style"),
87
# ("STC_FORTH_CONTROL", ""),
88
# ("STC_FORTH_DEFWORD", ""),
89
# ("STC_FORTH_IDENTIFIER", ""),
90
(stc.STC_FORTH_KEYWORD, "keyword_style"),
91
# ("STC_FORTH_LOCALE", ""),
92
(stc.STC_FORTH_NUMBER, "number_style"),
93
(stc.STC_FORTH_PREWORD1, "keyword2_style"),
94
(stc.STC_FORTH_PREWORD2, "keyword3_style"),
95
(stc.STC_FORTH_STRING, "string_style")]
98
#---- Extra Properties ----#
100
#-----------------------------------------------------------------------------#
102
class SyntaxData(syndata.SyntaxDataBase):
103
"""SyntaxData object for Forth"""
104
def __init__(self, langid):
105
syndata.SyntaxDataBase.__init__(self, langid)
108
self.SetLexer(stc.STC_LEX_FORTH)
110
def GetKeywords(self):
111
"""Returns Specified Keywords List """
112
return [CONTROL_KW, KEYWORDS, DEFINITION_KW,
113
PREWORDS1, PREWORDS2, STRING_DEF_KW]
115
def GetSyntaxSpec(self):
116
"""Syntax Specifications """
119
def GetCommentPattern(self):
120
"""Returns a list of characters used to comment a block of code """