ThirdParty/Pygments/pygments/lexers/asm.py

changeset 684
2f29a0b6e1c7
parent 0
de9c2efb9d02
child 1112
8a7d1b9d18db
--- a/ThirdParty/Pygments/pygments/lexers/asm.py	Sat Oct 16 20:28:00 2010 +0200
+++ b/ThirdParty/Pygments/pygments/lexers/asm.py	Wed Oct 20 08:39:56 2010 +0200
@@ -5,15 +5,11 @@
 
     Lexers for assembly languages.
 
-    :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
 import re
-try:
-    set
-except NameError:
-    from sets import Set as set
 
 from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
 from pygments.lexers.compiled import DLexer, CppLexer, CLexer
@@ -199,7 +195,7 @@
 
     #: optional Comment or Whitespace
     string = r'"[^"]*?"'
-    identifier = r'([a-zA-Z$._][a-zA-Z$._0-9]*|' + string + ')'
+    identifier = r'([-a-zA-Z$._][-a-zA-Z$._0-9]*|' + string + ')'
 
     tokens = {
         'root': [
@@ -211,14 +207,17 @@
             include('keyword'),
 
             (r'%' + identifier, Name.Variable),#Name.Identifier.Local),
-            (r'@' + identifier, Name.Constant),#Name.Identifier.Global),
+            (r'@' + identifier, Name.Variable.Global),#Name.Identifier.Global),
             (r'%\d+', Name.Variable.Anonymous),#Name.Identifier.Anonymous),
+            (r'@\d+', Name.Variable.Global),#Name.Identifier.Anonymous),
+            (r'!' + identifier, Name.Variable),
+            (r'!\d+', Name.Variable.Anonymous),
             (r'c?' + string, String),
 
             (r'0[xX][a-fA-F0-9]+', Number),
             (r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number),
 
-            (r'[=<>{}\[\]()*.,]|x\b', Punctuation)
+            (r'[=<>{}\[\]()*.,!]|x\b', Punctuation)
         ],
         'whitespace': [
             (r'(\n|\s)+', Text),
@@ -226,36 +225,56 @@
         ],
         'keyword': [
             # Regular keywords
-            (r'(void|label|float|double|opaque'
-             r'|to'
-             r'|alias|type'
-             r'|zeroext|signext|inreg|sret|noalias|noreturn|nounwind|nest'
-             r'|module|asm|target|datalayout|triple'
-             r'|true|false|null|zeroinitializer|undef'
-             r'|global|internal|external|linkonce|weak|appending|extern_weak'
-             r'|dllimport|dllexport'
-             r'|ccc|fastcc|coldcc|cc|tail'
-             r'|default|hidden|protected'
-             r'|thread_local|constant|align|section'
-             r'|define|declare'
+            (r'(begin|end'
+             r'|true|false'
+             r'|declare|define'
+             r'|global|constant'
+
+             r'|private|linker_private|internal|available_externally|linkonce'
+             r'|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport'
+             r'|common|default|hidden|protected|extern_weak|external'
+             r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple'
+             r'|deplibs|datalayout|volatile|nuw|nsw|exact|inbounds|align'
+             r'|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
+
+             r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
+             r'|arm_aapcscc|arm_aapcs_vfpcc'
+
+             r'|cc|c'
+
+             r'|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture'
+             r'|byval|nest|readnone|readonly'
 
-             # Statements & expressions
-             r'|trunc|zext|sext|fptrunc|fpext|fptoui|fptosi|uitofp|sitofp'
-             r'|ptrtoint|inttoptr|bitcast|getelementptr|select|icmp|fcmp'
-             r'|extractelement|insertelement|shufflevector'
-             r'|sideeffect|volatile'
-             r'|ret|br|switch|invoke|unwind|unreachable'
-             r'|add|sub|mul|udiv|sdiv|fdiv|urem|srem|frem'
-             r'|shl|lshr|ashr|and|or|xor'
-             r'|malloc|free|alloca|load|store'
-             r'|phi|call|va_arg|va_list'
+             r'|inlinehint|noinline|alwaysinline|optsize|ssp|sspreq|noredzone'
+             r'|noimplicitfloat|naked'
+
+             r'|type|opaque'
+
+             r'|eq|ne|slt|sgt|sle'
+             r'|sge|ult|ugt|ule|uge'
+             r'|oeq|one|olt|ogt|ole'
+             r'|oge|ord|uno|ueq|une'
+             r'|x'
 
-             # Comparison condition codes for icmp
-             r'|eq|ne|ugt|uge|ult|ule|sgt|sge|slt|sle'
-             # Ditto for fcmp: (minus keywords mentioned in other contexts)
-             r'|oeq|ogt|oge|olt|ole|one|ord|ueq|ugt|uge|une|uno'
+             # instructions
+             r'|add|fadd|sub|fsub|mul|fmul|udiv|sdiv|fdiv|urem|srem|frem|shl'
+             r'|lshr|ashr|and|or|xor|icmp|fcmp'
+
+             r'|phi|call|trunc|zext|sext|fptrunc|fpext|uitofp|sitofp|fptoui'
+             r'fptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch'
+             r'|invoke|unwind|unreachable'
+
+             r'|malloc|alloca|free|load|store|getelementptr'
+
+             r'|extractelement|insertelement|shufflevector|getresult'
+             r'|extractvalue|insertvalue'
 
              r')\b', Keyword),
+
+            # Types
+            (r'void|float|double|x86_fp80|fp128|ppc_fp128|label|metadata',
+             Keyword.Type),
+
             # Integer types
             (r'i[1-9]\d*', Keyword)
         ]
@@ -272,7 +291,7 @@
     mimetypes = ['text/x-nasm']
 
     identifier = r'[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*'
-    hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9a-fA-F]+h)'
+    hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9]+[0-9a-fA-F]*h)'
     octn = r'[0-7]+q'
     binn = r'[01]+b'
     decn = r'[0-9]+'
@@ -284,7 +303,8 @@
     wordop = r'seg|wrt|strict'
     type = r'byte|[dq]?word'
     directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
-                  r'COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE')
+                  r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|'
+                  r'EXPORT|LIBRARY|MODULE')
 
     flags = re.IGNORECASE | re.MULTILINE
     tokens = {
@@ -292,10 +312,10 @@
             include('whitespace'),
             (r'^\s*%', Comment.Preproc, 'preproc'),
             (identifier + ':', Name.Label),
+            (r'(%s)(\s+)(equ)' % identifier,
+                bygroups(Name.Constant, Keyword.Declaration, Keyword.Declaration),
+                'instruction-args'),
             (directives, Keyword, 'instruction-args'),
-            (r'(%s)\s+(equ)' % identifier,
-                bygroups(Name.Constant, Keyword.Declaration),
-                'instruction-args'),
             (declkw, Keyword.Declaration, 'instruction-args'),
             (identifier, Name.Function, 'instruction-args'),
             (r'[\r\n]+', Text)

eric ide

mercurial