You are here: Home / Past Courses / Spring 2013 - ECPE 170 / Tutorials / mips.lang

mips.lang

Extensible Markup Language (XML) icon mips.lang — Extensible Markup Language (XML), 7 KB (7883 bytes)

File contents

<?xml version="1.0" encoding="UTF-8"?>

<!--

 Modified by Warren Whitman to add missing peices.
 Original Credits below.

-->

<!--
 
 Author: Ben West
 Copyright (C) 2010 Ben West
 edited by Martin Thoma
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
 
-->

<!--
    Somewhat copied and pasted from nasm.lang
-->
<language id="mal" _name="MIPS" version="2.0" _section="Others">
    <metadata>
      <property name="mimetypes">text/mal</property>
      <property name="globs">*.asm</property>
      <property name="line-comment-start">#</property>
    </metadata>
 
    <styles>
        <style id="comment"              _name="Comment"                 map-to="def:comment"/>
        <style id="error"                _name="Error"                   map-to="def:error"/>
        <style id="string"               _name="String"                  map-to="def:string"/>
        <style id="preprocessor"         _name="Preprocessor"            map-to="def:preprocessor"/>
        <style id="opcode"               _name="Opcode"                  map-to="def:keyword"/>
        <style id="register"             _name="Register"                map-to="def:special-char"/>
        <style id="type"                 _name="Data Type"               map-to="def:type"/>
        <style id="escaped-character"    _name="Escaped Character"       map-to="def:special-char"/>
        <style id="decimal"              _name="Decimal number"      map-to="def:decimal"/>
        <style id="hexadecimal"  _name="Hexadecimal number"  map-to="def:base-n-integer"/>
        <style id="label"        _name="Label"           map-to="def:identifier" />
    </styles>
     
    <default-regex-options case-sensitive="false"/>
 
    <definitions>
        <define-regex id="escaped-character" extended="true">
            \\(      # leading backslash
            [\\\"\'] # escaped character
            )
        </define-regex>
 
        <context id="mal">
            <include> 
        <context id="preprocessor" style-ref="preprocessor">
            <prefix>^\s?\.</prefix>
            <keyword>data</keyword>
            <keyword>text</keyword>
            <keyword>globl</keyword>
        </context>
 
                <context id="comment" style-ref="comment" end-at-line-end="true">
                    <start>#</start>
                    <include>
                      <context ref="def:in-line-comment"/>
                    </include>
                </context>
 
                <context id="string" style-ref="string" end-at-line-end="true">
                    <start>"</start>
                    <end>"</end>
                    <include>
                        <context id="escaped-characterw" style-ref="escaped-character">
                            <match>\%{escaped-character}</match>
                        </context>
                    </include>
                </context>
                <context id="string2" style-ref="string" end-at-line-end="true">
                    <start>'</start>
                    <end>'</end>
                    <include>
                        <context id="escaped-characters" style-ref="escaped-character">
                            <match>\%{escaped-character}</match>
                        </context>
                    </include>
                </context>
 
 
            <context id="hexadecimal-number" style-ref="hexadecimal">
                <match extended="true">
            (?&lt;![\w\.])
            [+-]?0x[0-9a-fA-F]+
            (?![\w\.])
                </match>
            </context>
 
                <context id="decimal" style-ref="decimal">
                    <match extended="true">
                        (?&lt;![\w\.])
                        (-?)[0-9]+
                        (?![\w\.])
                    </match>
                </context>
 
                <context id="registers" style-ref="register">         
            <match extended="true">
                (\$
                    (
                        \d|[12]\d|3[12]|
                        (ra)|
                        ([vk][01])|
                        (a[0-3t])|
                        (t[0-9])|
                        (s[0-7p])|
                        ([gsf]p)|
                        (zero)
                    )
                )\b
            </match>          
                </context>
 
        <context id="label" style-ref="label">
            <match extended="true">
                \w+:
            </match>
        </context>
 
                <!-- Opcodes -->
        <context id="opcodes_simple" style-ref="opcode">
            <!-- MAL Opcodes -->
            <keyword>la</keyword>
            <keyword>li</keyword>
            <keyword>lw</keyword>
            <keyword>lb</keyword>
            <keyword>lbu</keyword>
            <keyword>lui</keyword>
            <keyword>sw</keyword>
            <keyword>sb</keyword>
            <keyword>add(i?)(u?)(\.s)?</keyword>
            <keyword>sub(u?)(\.s)?</keyword>
            <keyword>mul(u?)(\.s)?</keyword>
            <keyword>div(u?)(\.s)?</keyword>
            <keyword>rem</keyword>
            <keyword>and(i?)</keyword>
            <keyword>or(i?)</keyword>
            <keyword>xor(i?)</keyword>
            <keyword>nor</keyword>
            <keyword>not</keyword>
            <keyword>move</keyword>
            <keyword>sll(v?)</keyword>
            <keyword>srl(v?)</keyword>
            <keyword>sra</keyword>
            <keyword>l\.s</keyword>
            <keyword>s\.s</keyword>
            <keyword>mov\.s</keyword>
            <keyword>cvt\.s\.w</keyword>
            <keyword>cvt\.w\.s</keyword>
            <keyword>mfc0</keyword>
            <keyword>mtc0</keyword>
            <keyword>mfc1</keyword>
            <keyword>mtc1</keyword>
            <keyword>b </keyword>
            <keyword>beq</keyword>
            <keyword>bne</keyword>
            <keyword>blt</keyword>
            <keyword>bgt</keyword>
            <keyword>ble</keyword>
            <keyword>bge</keyword>
            <keyword>bltz(al)?</keyword>
            <keyword>bgtz</keyword>
            <keyword>blez</keyword>
            <keyword>bgez(al)?</keyword>
            <keyword>bnez</keyword>
            <keyword>beqz</keyword>
            <keyword>j </keyword>
            <keyword>jr</keyword>
            <keyword>jal</keyword>
            <keyword>jalr</keyword>
            <keyword>getc</keyword>
            <keyword>putc</keyword>
            <keyword>puts</keyword>
            <keyword>done</keyword>
            <keyword>syscall</keyword>
            <keyword>mf(hi|lo)</keyword>
            <keyword>neg</keyword>
            <keyword>noop</keyword>
            <keyword>slt(i?)(u?)</keyword>
                </context>                               
                 
                <context id="types" style-ref="type">
            <prefix>\.</prefix>
            <keyword>byte</keyword>
            <keyword>word</keyword>
            <keyword>asciiz</keyword>
            <keyword>ascii</keyword>
            <keyword>float</keyword>
            <keyword>space</keyword>
                </context>         
            </include>
        </context>
    </definitions>
</language>