Commit 6c99efdc authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2005-08-07 Benoît Perrot <benoit@lrde.epita.fr>

	* dev/nolimips.py, dev/nolimips.xml: Introduce predefined syntaxes
	to reduce data redundancy.
parent e7ae3852
2005-07-31 Benot Perrot <benoit@nostromo.lrde.epita.fr>
2005-08-07 Benot Perrot <benoit@lrde.epita.fr>
* dev/nolimips.py, dev/nolimips.xml: Introduce predefined syntaxes
to reduce data redundancy.
2005-07-31 Benot Perrot <benoit@lrde.epita.fr>
Move generators to source directories.
......@@ -16,12 +21,12 @@
* Makefile.am:
Update accordingly.
2005-07-31 Benot Perrot <benoit@nostromo.lrde.epita.fr>
2005-07-31 Benot Perrot <benoit@lrde.epita.fr>
* configure.ac: Bump to 0.8a
* NEWS: Fix release date.
2005-07-11 Benot Perrot <benoit@nostromo.lrde.epita.fr>
2005-07-11 Benot Perrot <benoit@lrde.epita.fr>
* configure.ac: Bump to 0.8.
......
#!/usr/bin/env python
##
## This file is part of Nolimips, a MIPS simulator with unlimited registers
## Copyright (C) 2003, 2004 Benoit Perrot <benoit@lrde.epita.fr>
## Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
##
## Nolimips is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
......@@ -26,7 +26,7 @@ from xml.sax import ContentHandler, make_parser
license = """//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Benoit Perrot <benoit@lrde.epita.fr>
// Copyright (C) 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -183,8 +183,27 @@ class SyntaxBuilder:
def reset(self):
self.tokens = []
self.alias = ""
self.level = ""
def __init__(self):
self.reset()
def set_to_predefined(self, template, alias, level):
self.alias = alias
self.level = level
if template == "register":
self.tokens = [
Token("register", "dest", "", ""),
Token("register", "", "", "${dest}"),
Token("register", "", "", "")]
elif template == "immediate":
self.tokens = [
Token("register", "dest", "", ""),
Token("register", "", "", "${dest}"),
Token("immediate", "", "", "")]
elif template == "jump":
self.tokens = [
Token("register", "", "", ""),
Token("register", "", "", ""),
Token("label", "", "", "")]
def get(self):
return Syntax(self.tokens, self.alias, self.level)
......@@ -268,6 +287,16 @@ class InstructionSetHandler(ContentHandler):
self.syntax_b.level = attrs["level"]
else:
self.syntax_b.level = self.inst_b.level
elif name == "predefinedSyntax":
alias = ""
if attrs.has_key("alias"):
alias = attrs["alias"]
level = ""
if attrs.has_key("level"):
level = attrs["level"]
else:
level = self.inst_b.level
self.syntax_b.set_to_predefined(attrs["template"], alias, level)
elif name == "token":
self.token_b.reset()
self.token_b.kind = attrs["kind"]
......@@ -281,7 +310,7 @@ class InstructionSetHandler(ContentHandler):
def endElement(self, name):
if name == "token":
self.syntax_b.tokens.append(self.token_b.get())
elif name == "syntax":
elif name == "syntax" or name == "predefinedSyntax":
self.inst_b.syntaxes.append(self.syntax_b.get())
if name == "attribute":
self.format_b.attributes.append(self.attr_b.get())
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment