~ubuntu-branches/ubuntu/trusty/wxwidgets2.8/trusty

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/src/syntax/_forth.py

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2013-11-30 21:11:54 UTC
  • mfrom: (1.1.10) (5.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20131130211154-xfa8ttxc4n0zo9jd
Tags: 2.8.12.1+dfsg-2ubuntu1
* Merge with Debian unstable (LP: #1253003), remaining changes:
  - Disable bp-menubar-fix.patch.
  - Disable disable_media_python.patch to add wx.media to python-wxgtk2.8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
###############################################################################
2
 
# Name: forht.py                                                              #
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
 
###############################################################################
8
 
 
9
 
"""
10
 
FILE: _forth.py
11
 
AUTHOR: Cody Precord
12
 
@summary: Lexer configuration module for Forth
13
 
 
14
 
"""
15
 
 
16
 
__author__ = "Cody Precord <cprecord@editra.org>"
17
 
__svnid__ = "$Id: _forth.py 63834 2010-04-03 06:04:33Z CJP $"
18
 
__revision__ = "$Revision: 63834 $"
19
 
 
20
 
#-----------------------------------------------------------------------------#
21
 
# Imports
22
 
import wx.stc as stc
23
 
 
24
 
# Local Imports
25
 
import synglob
26
 
import syndata
27
 
 
28
 
#-----------------------------------------------------------------------------#
29
 
 
30
 
#---- Keyword Definitions ----#
31
 
 
32
 
# Control Keywords
33
 
CONTROL_KW = (0, "again begin case do else endcase endof if loop of "
34
 
                 "repeat then until while [if] [else] [then] ?do")
35
 
 
36
 
# Keywords
37
 
KEYWORDS = (1, "dup drop rot swap over @ ! 2@ 2! 2dup 2drop 2swap 2over nip "
38
 
               "r@ >r r&gt; 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")
65
 
 
66
 
# Definition Keywords
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: "
70
 
                    "cez: module:")
71
 
 
72
 
# Prewords with one argument
73
 
PREWORDS1 = (3, "CHAR [CHAR] POSTPONE WITH ['] TO [COMPILE] CHAR ASCII \\'")
74
 
 
75
 
# Prewords with two arguments
76
 
PREWORDS2 = (4, "REQUIRE WINAPI:")
77
 
 
78
 
# String definition Keywords
79
 
STRING_DEF_KW = (5, "S\" ABORT\" Z\" \" .\" C\"")
80
 
 
81
 
#---- End Keyword Definitions ----#
82
 
 
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")]
96
 
 
97
 
 
98
 
#---- Extra Properties ----#
99
 
 
100
 
#-----------------------------------------------------------------------------#
101
 
 
102
 
class SyntaxData(syndata.SyntaxDataBase):
103
 
    """SyntaxData object for Forth""" 
104
 
    def __init__(self, langid):
105
 
        syndata.SyntaxDataBase.__init__(self, langid)
106
 
 
107
 
        # Setup
108
 
        self.SetLexer(stc.STC_LEX_FORTH)
109
 
 
110
 
    def GetKeywords(self):
111
 
        """Returns Specified Keywords List """
112
 
        return [CONTROL_KW, KEYWORDS, DEFINITION_KW,
113
 
                PREWORDS1, PREWORDS2, STRING_DEF_KW]
114
 
 
115
 
    def GetSyntaxSpec(self):
116
 
        """Syntax Specifications """
117
 
        return SYNTAX_ITEMS
118
 
 
119
 
    def GetCommentPattern(self):
120
 
        """Returns a list of characters used to comment a block of code """
121
 
        return [u'\\ ']