Commits

Georg Brandl committed bacdff3

Fixed LLVM lexer identifier syntax and added new keywords (#442).

Comments (0)

Files changed (2)

 
 - Added the Monokai style (#453).
 
+- Fixed LLVM lexer identifier syntax and added new keywords (#442).
+
 - Fixed the PythonTracebackLexer to handle non-traceback data in header or
   trailer, and support more partial tracebacks that start on line 2 (#437).
 

pygments/lexers/asm.py

 
     #: 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': [
             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),
         ],
         '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'
 
-             # 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'|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'
 
-             # new float ops
-             r'|fadd|fsub|fmul'
+             r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
+             r'|arm_aapcscc|arm_aapcs_vfpcc'
 
-             # 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'
+             r'|cc|c'
+
+             r'|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture'
+             r'|byval|nest|readnone|readonly'
+
+             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'
+
+             # 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)
         ]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.