_asm.py
3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
###############################################################################
# Name: asm.py #
# Purpose: Define ASM syntax for highlighting and other features #
# Author: Cody Precord <cprecord@editra.org> #
# Copyright: (c) 2007 Cody Precord <staff@editra.org> #
# License: wxWindows License #
###############################################################################
"""
FILE: asm.py
AUTHOR: Cody Precord
@summary: Lexer configuration file GNU Assembly Code
@todo: Complete Keywords/Registers
"""
__author__ = "Cody Precord <cprecord@editra.org>"
__svnid__ = "$Id: _asm.py 70228 2011-12-31 20:39:16Z CJP $"
__revision__ = "$Revision: 70228 $"
#-----------------------------------------------------------------------------#
# Imports
import wx.stc as stc
# Local Imports
import synglob
import syndata
#-----------------------------------------------------------------------------#
# GNU Assembly CPU Instructions/Storage Types
ASM_CPU_INST = (0, ".long .ascii .asciz .byte .double .float .hword .int .octa "
".quad .short .single .space .string .word")
# GNU FPU Instructions
ASM_MATH_INST = (1, "")
# GNU Registers
ASM_REGISTER = (2, "")
# GNU Assembly Directives/Special statements/Macros
ASM_DIRECTIVES = (3, ".include .macro .endm")
#---- Language Styling Specs ----#
SYNTAX_ITEMS = [ (stc.STC_ASM_DEFAULT, 'default_style'),
(stc.STC_ASM_CHARACTER, 'char_style'),
(stc.STC_ASM_COMMENT, 'comment_style'),
(stc.STC_ASM_COMMENTBLOCK, 'comment_style'),
(stc.STC_ASM_CPUINSTRUCTION, 'keyword_style'),
(stc.STC_ASM_DIRECTIVE, 'keyword3_style'),
(stc.STC_ASM_DIRECTIVEOPERAND, 'default_style'),
(stc.STC_ASM_EXTINSTRUCTION, 'default_style'),
(stc.STC_ASM_IDENTIFIER, 'default_style'),
(stc.STC_ASM_MATHINSTRUCTION, 'keyword_style'),
(stc.STC_ASM_NUMBER, 'number_style'),
(stc.STC_ASM_OPERATOR, 'operator_style'),
(stc.STC_ASM_REGISTER, 'keyword2_style'),
(stc.STC_ASM_STRING, 'string_style'),
(stc.STC_ASM_STRINGEOL, 'stringeol_style') ]
#-----------------------------------------------------------------------------#
class SyntaxData(syndata.SyntaxDataBase):
"""SyntaxData object for Assembly files"""
def __init__(self, langid):
super(SyntaxData, self).__init__(langid)
# Setup
# synglob.ID_LANG_ASM
self.SetLexer(stc.STC_LEX_ASM)
def GetKeywords(self):
"""Returns List of Keyword Specifications """
return [ASM_CPU_INST, ASM_DIRECTIVES]
def GetSyntaxSpec(self):
"""Syntax Specifications """
return SYNTAX_ITEMS
def GetCommentPattern(self):
"""Returns a list of characters used to comment a block of code """
return [u';']