* dev/nolimips.py, doc/inst-set.texi.gen.py, src/inst/nodes.gen.py,
* src/inst/nodes.mk.gen.py, src/inst/program_builder.hh.gen.py,
* src/inst/program_solver.gen.py, src/parse/asm-parse.yy.gen.py,
* src/parse/asm-scan.ll.gen.py:
Untabify.
---
dev/nolimips.py | 24 +++---
doc/inst-set.texi.gen.py | 8 +-
src/inst/nodes.gen.py | 16 ++--
src/inst/nodes.mk.gen.py | 12 +-
src/inst/program_builder.hh.gen.py | 24 +++---
src/inst/program_solver.gen.py | 112 +++++++++++-----------
src/parse/asm-parse.yy.gen.py | 38 ++++----
src/parse/asm-scan.ll.gen.py | 180 ++++++++++++++++++------------------
8 files changed, 207 insertions(+), 207 deletions(-)
mode change 100755 => 100644 dev/nolimips.py
diff --git a/dev/nolimips.py b/dev/nolimips.py
old mode 100755
new mode 100644
index 53e2205..e0d8226
--- a/dev/nolimips.py
+++ b/dev/nolimips.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -31,12 +31,12 @@ license = """//
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// Nolimips 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 General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -181,7 +181,7 @@ class TokenBuilder:
def reset(self):
self.kind = ""
self.name = ""
- self.value = ""
+ self.value = ""
self.default = ""
def __init__(self):
self.reset()
@@ -281,17 +281,17 @@ class InstructionSetHandler(ContentHandler):
self.content = ""
def __init__(self):
self.reset()
-
+
def startElement(self, name, attrs):
if name == "instruction":
self.inst_b.reset()
self.inst_b.opcode = attrs["opcode"]
self.inst_b.level = attrs["level"]
self.inst_b.kind = attrs["kind"]
-
+
elif name == "description":
self.content = ""
-
+
elif name == "format":
self.format_b = FormatBuilder()
if attrs.has_key("type"):
@@ -339,17 +339,17 @@ class InstructionSetHandler(ContentHandler):
self.syntax_b.tokens.append(self.token_b.get())
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())
elif name == "predefinedAttributes":
self.inst_b.format = self.format_b.get()
elif name == "format":
self.inst_b.format = self.format_b.get()
-
+
elif name == "description":
self.inst_b.desc = self.content
-
+
elif name == "instruction":
self.instructions.append(self.inst_b.get())
@@ -365,7 +365,7 @@ class InstructionSetParser:
h = InstructionSetHandler()
# Tell the parser to use our handler
parser.setContentHandler(h)
-
+
# Parse the input
parser.parse(file)
diff --git a/doc/inst-set.texi.gen.py b/doc/inst-set.texi.gen.py
index 520f66e..9481059 100755
--- a/doc/inst-set.texi.gen.py
+++ b/doc/inst-set.texi.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -55,10 +55,10 @@ for inst in instructions:
kind = inst.kind
print "@node " + string.capwords(kind) + " instructions"
print "@subsection " + string.capwords(kind) + " instructions"
-
+
desc = string.replace(inst.desc, "\n", " ")
desc = string.replace(desc, " ", " ")
-
+
print "@subsubsection " + string.upper(inst.opcode)
print "@findex " + string.upper(inst.opcode)
print desc
diff --git a/src/inst/nodes.gen.py b/src/inst/nodes.gen.py
index 10c6d91..57abaad 100755
--- a/src/inst/nodes.gen.py
+++ b/src/inst/nodes.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -44,12 +44,12 @@ def class_generate(inst):
file_id = nolimips.file_id(inst.opcode)
banner = nolimips.license + "\n" + nolimips.generated_by_hand
format = inst.format
-
+
## Open header, inline and implementation files
header = file(file_id + ".hh.tmp", "w")
inline = file(file_id + ".hxx.tmp", "w")
impl = file(file_id + ".cc.tmp", "w")
-
+
for f, ext, brief in [(header, "hh", "Declare the interface"),
(inline, "hxx", "Inline methods"),
(impl, "cc", "Implementation")]:
@@ -71,7 +71,7 @@ def class_generate(inst):
sys.stdout = impl
print "#include \"inst/visitor.hh\""
-
+
for f in [inline, impl]:
sys.stdout = f
print "#include \"inst/" + file_id + ".hh\""
@@ -91,13 +91,13 @@ namespace inst
print " class " + class_id + ":"
print " public Inst"
print " {"
-
+
# Constructor and destructor
args = ""
init = ""
dels = ""
for attribute in format.attributes:
-
+
if attribute.type == "Register":
args = args + "const " + attribute.type + " &"
elif attribute.type == "Exp":
@@ -159,7 +159,7 @@ namespace inst
print " }"
sys.stdout = header
print " /** \\} */"
-
+
# Method: visitor entry point
sys.stdout = inline
print ""
diff --git a/src/inst/nodes.mk.gen.py b/src/inst/nodes.mk.gen.py
index 0996a0a..52a8b0b 100755
--- a/src/inst/nodes.mk.gen.py
+++ b/src/inst/nodes.mk.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -28,13 +28,13 @@ from nolimips import depth
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
-print "FROM_NODES_GEN_PY = \\"
+print "FROM_NODES_GEN_PY = \\"
for i in range(0, len(instructions)):
if instructions[i].level == "native":
line = "\t"
for ext in ["hh", "hxx", "cc"]:
line = line + instructions[i].opcode + "." + ext + " "
print line + "\t\t\\"
-print """ fwd.hh \\
- all.hh \\
- visitor.hh"""
+print """ fwd.hh \\
+ all.hh \\
+ visitor.hh"""
diff --git a/src/inst/program_builder.hh.gen.py b/src/inst/program_builder.hh.gen.py
index e9803b0..20b7bd6 100755
--- a/src/inst/program_builder.hh.gen.py
+++ b/src/inst/program_builder.hh.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -52,7 +52,7 @@ namespace inst
{
using vm::Cpu;
-
+
class ProgramBuilder
{
public:
@@ -62,9 +62,9 @@ namespace inst
void reset();
void set_nop_after_branch(bool nop_after_branch_p);
-
+
Program *get();
-
+
public:
void define_inst_label(const misc::unique_string &id);
void define_data_label(const misc::unique_string &id);
@@ -95,7 +95,7 @@ for inst in instructions:
for syntax in inst.syntaxes:
if (syntax.alias != "") or (syntax.level == "pseudo"):
continue
-
+
if syntax.level == "native":
proto = ""
call = ""
@@ -112,14 +112,14 @@ for inst in instructions:
print " program_->text_section().add_inst (" + call +
");"
if inst.kind == "branch":
print " if (nop_after_branch_p_)"
- print " program_->text_section()."
- print " add_inst (new Sll(Register(Register::general, " + \
+ print " program_->text_section()."
+ print " add_inst (new Sll(Register(Register::general, " + \
"Cpu::zero), "
- print " Register(Register::general, " + \
+ print " Register(Register::general, " + \
"Cpu::zero), "
- print " new IntExp(0)));"
+ print " new IntExp(0)));"
print " }"
-
+
else: # syntax.level == "complex"
proto = ""
for token in syntax.tokens:
@@ -129,7 +129,7 @@ for inst in instructions:
proto = proto + ", "
proto = string.rstrip(proto, ", ")
print " void\tadd_" + inst.opcode + "(" + proto +
");"
-
+
print """
protected:
Program *program_;
diff --git a/src/inst/program_solver.gen.py b/src/inst/program_solver.gen.py
index 1543eb2..a85bb86 100755
--- a/src/inst/program_solver.gen.py
+++ b/src/inst/program_solver.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -52,7 +52,7 @@ namespace inst
{
class ProgramSolver:
- protected Visitor,
+ protected Visitor,
protected ExpVisitor
{
public:
@@ -84,9 +84,9 @@ namespace inst
print " protected:"
for inst in instructions:
if inst.level == "native":
- print " virtual void visit(" +\
+ print " virtual void visit(" +\
nolimips.class_id(inst.opcode) + " &);"
-
+
print """
protected:
Program *program_;
@@ -144,14 +144,14 @@ namespace inst
{
if (! program_->data_section().has_label(l.get_name()))
if (! program_->text_section().has_label(l.get_name()))
- {
- std::cerr << \"Undefined label: \" << l.get_name()
- << std::endl;
- exit_set(exit_solve);
- }
+ {
+ std::cerr << \"Undefined label: \" << l.get_name()
+ << std::endl;
+ exit_set(exit_solve);
+ }
else
- l.set_immediate(program_->text_section().
- get_offset(l.get_name()) - pc_);
+ l.set_immediate(program_->text_section().
+ get_offset(l.get_name()) - pc_);
else
l.set_immediate(program_->data_section().get_offset(l.get_name()));
}
@@ -164,21 +164,21 @@ namespace inst
switch (o.kind_)
{
case OpExp::add:
- o.set_immediate(o.get_left().get_immediate() +
- o.get_right().get_immediate());
- break;
+ o.set_immediate(o.get_left().get_immediate() +
+ o.get_right().get_immediate());
+ break;
case OpExp::sub:
- o.set_immediate(o.get_left().get_immediate() -
- o.get_right().get_immediate());
- break;
- case OpExp::mul:
- o.set_immediate(o.get_left().get_immediate() *
- o.get_right().get_immediate());
- break;
+ o.set_immediate(o.get_left().get_immediate() -
+ o.get_right().get_immediate());
+ break;
+ case OpExp::mul:
+ o.set_immediate(o.get_left().get_immediate() *
+ o.get_right().get_immediate());
+ break;
case OpExp::div:
- o.set_immediate(o.get_left().get_immediate() /
- o.get_right().get_immediate());
- break;
+ o.set_immediate(o.get_left().get_immediate() /
+ o.get_right().get_immediate());
+ break;
}
}
@@ -188,46 +188,46 @@ namespace inst
switch (reg.get_kind())
{
case Register::generic:
- reg.set_kind(Register::general);
+ reg.set_kind(Register::general);
case Register::general:
- if ((reg.get_index() == vm::Cpu::t9 && max_caller_save_ < 10)
- || (reg.get_index() == vm::Cpu::t8 && max_caller_save_ < 9)
- || (vm::Cpu::t0 + max_caller_save_ - 1 < reg.get_index()
- && reg.get_index() <= vm::Cpu::t7))
- {
- std::cerr << \"Caller-save register limited.\" << std::endl;
- exit_set(exit_solve);
- }
- else if (vm::Cpu::s0 + max_callee_save_ - 1 < reg.get_index() &&
- reg.get_index() <= vm::Cpu::s7)
- {
- std::cerr << \"Callee-save register limited.\" << std::endl;
- exit_set(exit_solve);
- }
+ if ((reg.get_index() == vm::Cpu::t9 && max_caller_save_ < 10)
+ || (reg.get_index() == vm::Cpu::t8 && max_caller_save_ < 9)
+ || (vm::Cpu::t0 + max_caller_save_ - 1 < reg.get_index()
+ && reg.get_index() <= vm::Cpu::t7))
+ {
+ std::cerr << \"Caller-save register limited.\" <<
std::endl;
+ exit_set(exit_solve);
+ }
+ else if (vm::Cpu::s0 + max_callee_save_ - 1 < reg.get_index() &&
+ reg.get_index() <= vm::Cpu::s7)
+ {
+ std::cerr << \"Callee-save register limited.\" <<
std::endl;
+ exit_set(exit_solve);
+ }
else if (vm::Cpu::a0 + max_args_ - 1 < reg.get_index() &&
- reg.get_index() <= vm::Cpu::a3)
+ reg.get_index() <= vm::Cpu::a3)
{
- std::cerr << \"Argument register limited.\" << std::endl;
- exit_set(exit_solve);
+ std::cerr << \"Argument register limited.\" <<
std::endl;
+ exit_set(exit_solve);
}
- break;
+ break;
case Register::unlimited:
- if (!unlimited_regs_enabled_)
- {
- std::cerr << \"Unlimited registers prohibited.\" <<
std::endl;
- exit_set(exit_solve);
- }
- break;
+ if (!unlimited_regs_enabled_)
+ {
+ std::cerr << \"Unlimited registers prohibited.\" <<
std::endl;
+ exit_set(exit_solve);
+ }
+ break;
};
}
-
+
void
ProgramSolver::solve_cop_register(Register ®) const
{
if (reg.get_kind() != Register::generic)
{
- std::cerr << \"Coprocessor registers must be generic.\" <<
std::endl;
- exit_set(exit_solve);
+ std::cerr << \"Coprocessor registers must be generic.\" <<
std::endl;
+ exit_set(exit_solve);
}
}
@@ -236,7 +236,7 @@ namespace inst
for inst in instructions:
if inst.level == "native":
var_id = nolimips.var_id(inst.opcode)
-
+
content = ""
for attribute in inst.format.attributes:
if attribute.type == "Exp":
@@ -248,7 +248,7 @@ for inst in instructions:
else:
content = content + " solve_cpu_register("
content = content + var_id + ".get_" + attribute.name +
"());\n"
-
+
print " void"
if content != "":
print " ProgramSolver::visit(" + nolimips.class_id(inst.opcode) + \
@@ -258,7 +258,7 @@ for inst in instructions:
print " ProgramSolver::visit(" + nolimips.class_id(inst.opcode) + "
&)"
print " {"
print " }"
-
+
print """
} // namespace inst"""
diff --git a/src/parse/asm-parse.yy.gen.py b/src/parse/asm-parse.yy.gen.py
index c85c33e..01b5e11 100755
--- a/src/parse/asm-parse.yy.gen.py
+++ b/src/parse/asm-parse.yy.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -36,7 +36,7 @@ instructions = parser.parse(sys.stdin)
sys.stdout = file("asm-parse.yy.tmp", "w")
## Prologue --------------------------
-print "%{ // -*- C++ -*-"
+print "%{ // -*- C++
-*-"
print nolimips.license
print nolimips.generated_by_hand
print """
@@ -73,9 +73,9 @@ using namespace inst;
%union
{
- int i;
- std::string *s;
- misc::unique_string *id;
+ int i;
+ std::string *s;
+ misc::unique_string *id;
inst::Label *label;
inst::Register *reg;
inst::Exp *exp;
@@ -84,8 +84,8 @@ using namespace inst;
#include \"parse/asm-scan.hh\"
%}
-%token <id> LABEL \"label\"
-%token <id> LABEL_DEF \"label definition\"
+%token <id> LABEL \"label\"
+%token <id> LABEL_DEF \"label definition\"
%token <i> INTEGER \"integer\"
%token <s> STRING \"string\"
%token <reg> REGISTER \"register\"
@@ -100,10 +100,10 @@ using namespace inst;
%type <exp> exp
-%token YYEOF 0 \"end of file\"
-%token LPAREN \"(\"
-%token RPAREN \")\"
-%token COMMA \",\"
+%token YYEOF 0 \"end of file\"
+%token LPAREN \"(\"
+%token RPAREN \")\"
+%token COMMA \",\"
%left EXP_ADD EXP_SUB
%left EXP_MUL EXP_DIV
@@ -119,15 +119,15 @@ using namespace inst;
%token DIR_ASCII \".ascii\"
%token DIR_ASCIIZ \".asciiz\"
"""
-
+
for i in instructions:
print "%token " + define_id(i.opcode) + '\t\t"' + i.opcode +
'"'
-
+
print """
-
+
%start program
%%
-//
+//
program
:
| program DIR_TEXT instructions
@@ -228,7 +228,7 @@ for inst in instructions:
i = i + 1
if i >= len(prod):
break
-
+
# Compute token indices
tokidx = {}
i = 0
@@ -238,7 +238,7 @@ for inst in instructions:
if token[1] != "":
assert(not tokidx.has_key(token[1]))
tokidx[token[1]] = i
-
+
# Build rule and action
rule = "|"
action = "program_builder.add_"
@@ -255,7 +255,7 @@ for inst in instructions:
rule = rule + " " + token[0]
value = "$" + str(i)
if token[2] != "":
- value = re.sub(r"\$\{([^}]*)\}",
+ value = re.sub(r"\$\{([^}]*)\}",
(lambda m: "$" + str(tokidx[m.groups(0)[0]])),
token[2])
if token[0] in tokid_map.values():
diff --git a/src/parse/asm-scan.ll.gen.py b/src/parse/asm-scan.ll.gen.py
index 48972ac..b1fe520 100755
--- a/src/parse/asm-scan.ll.gen.py
+++ b/src/parse/asm-scan.ll.gen.py
@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
-##
+##
## Nolimips 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 General Public License for more details.
-##
+##
## You should have received a copy of the GNU General Public License
## along with Nolimips. If not, see <http://www.gnu.org/licenses/>.
##
@@ -53,7 +53,7 @@ print """
#define YY_NEVER_INTERACTIVE 1
-#define YY_USER_ACTION \\
+#define YY_USER_ACTION \\
yylloc->columns (yyleng);
using inst::Register;
@@ -68,40 +68,40 @@ typedef yy::parser::token token;
%option debug
%x STATE_STRING
-eol \\n|\\r|\\n\\r|\\r\\n
+eol \\n|\\r|\\n\\r|\\r\\n
-dec_int [0-9]+
-hex_int 0x[0-9A-Fa-f]+
+dec_int [0-9]+
+hex_int 0x[0-9A-Fa-f]+
-id [a-zA-Z_][a-zA-Z_0-9]*
+id [a-zA-Z_][a-zA-Z_0-9]*
%%
%{
yylloc->step ();
%}
-[ \\t]+ yylloc->step ();
-[#;][^\\n\\r]* yylloc->step ();
-{eol} yylloc->lines (1); yylloc->step ();
+[ \\t]+ yylloc->step ();
+[#;][^\\n\\r]* yylloc->step ();
+{eol} yylloc->lines (1); yylloc->step ();
-\"(\" return token::LPAREN;
-\")\" return token::RPAREN;
-\",\" return token::COMMA;
+\"(\" return token::LPAREN;
+\")\" return token::RPAREN;
+\",\" return token::COMMA;
-\"+\" return token::EXP_ADD;
-\"-\" return token::EXP_SUB;
-\"*\" return token::EXP_MUL;
-\"/\" return token::EXP_DIV;
+\"+\" return token::EXP_ADD;
+\"-\" return token::EXP_SUB;
+\"*\" return token::EXP_MUL;
+\"/\" return token::EXP_DIV;
-\".text\" return token::DIR_TEXT;
-\".data\" return token::DIR_DATA;
+\".text\" return token::DIR_TEXT;
+\".data\" return token::DIR_DATA;
-\".space\" return token::DIR_SPACE;
-\".byte\" return token::DIR_BYTE;
-\".half\" return token::DIR_HALF;
-\".word\" return token::DIR_WORD;
-\".ascii\" return token::DIR_ASCII;
-\".asciiz\" return token::DIR_ASCIIZ;
+\".space\" return token::DIR_SPACE;
+\".byte\" return token::DIR_BYTE;
+\".half\" return token::DIR_HALF;
+\".word\" return token::DIR_WORD;
+\".ascii\" return token::DIR_ASCII;
+\".asciiz\" return token::DIR_ASCIIZ;
"""
## Body --------------------------------
@@ -111,54 +111,54 @@ for inst in instructions:
## Epilogue ----------------------------
print """
-\"$\"([0-9]|[12][0-9]|3[01]) {
+\"$\"([0-9]|[12][0-9]|3[01]) {
yylval->reg = new Register(Register::generic, atoi(yytext +1));
return token::REGISTER;
}
-\"$zero\" {
+\"$zero\" {
yylval->reg = new Register(Register::general, Cpu::zero);
return token::REGISTER;
}"""
for k, r in [("v", range(2)), ("a", range(4)),
("t", range(10)), ("s", range(8))]:
for i in r:
- print "\"$" + k + str(i) + "\" {"
+ print "\"$" + k + str(i) + "\" {"
print " yylval->reg = new Register(Register::general, " + \
"Cpu::" + k + str(i)+ ");"
print " return token::REGISTER;\n}"
print """
-\"$sp\" {
+\"$sp\" {
yylval->reg = new Register(Register::general, Cpu::sp);
return token::REGISTER;
}
-\"$fp\" {
+\"$fp\" {
yylval->reg = new Register(Register::general, Cpu::fp);
return token::REGISTER;
}
-\"$ra\" {
+\"$ra\" {
yylval->reg = new Register(Register::general, Cpu::ra);
return token::REGISTER;
}
-\"$x\"{dec_int} {
+\"$x\"{dec_int} {
yylval->reg = new Register(Register::unlimited, atoi(yytext +2));
return token::REGISTER;
}
-{id} {
+{id} {
yylval->id = new misc::unique_string(yytext);
return token::LABEL;
}
-{id}\":\" {
+{id}\":\" {
yytext[yyleng - 1] = 0; // Remove last character (side-effects on yytext are allowed)
yylval->id = new misc::unique_string(yytext);
return token::LABEL_DEF;
}
--?{dec_int} {
+-?{dec_int} {
std::istringstream iss(yytext);
if (iss.peek() == '-')
@@ -169,13 +169,13 @@ print """
if (iss.fail())
{
std::cerr << *yylloc
- << \": unrecognized integer (may be too large): \"
- << yytext << std::endl;
+ << \": unrecognized integer (may be too large): \"
+ << yytext << std::endl;
exit_set (exit_scan);
}
return token::INTEGER;
}
--?{hex_int} {
+-?{hex_int} {
std::istringstream iss(yytext);
if (iss.peek() == '-')
@@ -186,78 +186,78 @@ print """
if (iss.fail())
{
std::cerr << *yylloc
- << \": unrecognized integer (may be too large): \"
- << yytext << std::endl;
+ << \": unrecognized integer (may be too large): \"
+ << yytext << std::endl;
exit_set (exit_scan);
}
return token::INTEGER;
}
-'\\\\a' yylval->i = '\\a'; return token::INTEGER;
-'\\\\b' yylval->i = '\\b'; return token::INTEGER;
-'\\\\f' yylval->i = '\\f'; return token::INTEGER;
-'\\\\n' yylval->i = '\\n'; return token::INTEGER;
-'\\\\r' yylval->i = '\\r'; return token::INTEGER;
-'\\\\t' yylval->i = '\\t'; return token::INTEGER;
-'\\\\v' yylval->i = '\\v'; return token::INTEGER;
-'\\\\[\\\\\\']' yylval->i = yytext[1]; return token::INTEGER;
-'\\\\.' {
+'\\\\a' yylval->i = '\\a'; return token::INTEGER;
+'\\\\b' yylval->i = '\\b'; return token::INTEGER;
+'\\\\f' yylval->i = '\\f'; return token::INTEGER;
+'\\\\n' yylval->i = '\\n'; return token::INTEGER;
+'\\\\r' yylval->i = '\\r'; return token::INTEGER;
+'\\\\t' yylval->i = '\\t'; return token::INTEGER;
+'\\\\v' yylval->i = '\\v'; return token::INTEGER;
+'\\\\[\\\\\\']' yylval->i = yytext[1]; return token::INTEGER;
+'\\\\.' {
std::cerr << *yylloc
- << \": unrecognized escape: \" << escape (yytext) <<
std::endl;
+ << \": unrecognized escape: \" << escape (yytext)
<< std::endl;
exit_set (exit_scan);
}
-'[^\\'\\n\\r\\\\]' yylval->i = yytext[1]; return token::INTEGER;
+'[^\\'\\n\\r\\\\]' yylval->i = yytext[1]; return token::INTEGER;
-\\\" yylval->s = new std::string; BEGIN STATE_STRING;
+\\\" yylval->s = new std::string; BEGIN STATE_STRING;
<STATE_STRING>{
- \\\" {
+ \\\" {
BEGIN INITIAL;
return token::STRING;
}
- \\\\[0-7]{3} {
+ \\\\[0-7]{3} {
long c = strtol (yytext + 1, 0, 8);
if (c > 255)
{
- std::cerr << *yylloc
- << \": invalid escape: \" << escape (yytext) <<
std::endl;
- exit_set (exit_scan);
+ std::cerr << *yylloc
+ << \": invalid escape: \" << escape (yytext)
<< std::endl;
+ exit_set (exit_scan);
}
else
*(yylval->s) += c;
}
-
- \\\\x[0-9a-fA-F]{2} {
+
+ \\\\x[0-9a-fA-F]{2} {
*(yylval->s) += strtol (yytext + 2, 0, 16);
}
-
- \\\\a *(yylval->s) += '\\a';
- \\\\b *(yylval->s) += '\\b';
- \\\\f *(yylval->s) += '\\f';
- \\\\n *(yylval->s) += '\\n';
- \\\\r *(yylval->s) += '\\r';
- \\\\t *(yylval->s) += '\\t';
- \\\\v *(yylval->s) += '\\v';
- \\\\[\\\\\"\"] *(yylval->s) += yytext[1];
- \\\\. {
+
+ \\\\a *(yylval->s) += '\\a';
+ \\\\b *(yylval->s) += '\\b';
+ \\\\f *(yylval->s) += '\\f';
+ \\\\n *(yylval->s) += '\\n';
+ \\\\r *(yylval->s) += '\\r';
+ \\\\t *(yylval->s) += '\\t';
+ \\\\v *(yylval->s) += '\\v';
+ \\\\[\\\\\"\"] *(yylval->s) += yytext[1];
+ \\\\. {
std::cerr << *yylloc
- << \": unrecognized escape: \" << escape (yytext) <<
std::endl;
+ << \": unrecognized escape: \" << escape (yytext)
<< std::endl;
exit_set (exit_scan);
}
-
- [^\\\"\\n\\r\\\\]+ yylval->s->append (yytext, yyleng);
-
- {eol} {
+
+ [^\\\"\\n\\r\\\\]+ yylval->s->append (yytext, yyleng);
+
+ {eol} {
yylloc->lines (1);
yylval->s->append (\"\\n\", 1);
}
-
- <<EOF>> {
+
+ <<EOF>> {
std::cerr
<< *yylloc << \": unexpected end of file in a string\"
<< std::endl;
exit_set (exit_scan);
-
+
BEGIN INITIAL;
return token::STRING;
}
@@ -265,8 +265,8 @@ print """
. {
std::cerr << *yylloc
- << \": invalid character: `\"
- << escape (yytext) << \"'\" << std::endl;
+ << \": invalid character: `\"
+ << escape (yytext) << \"'\" << std::endl;
yylloc->step ();
exit_set (exit_scan);
}
@@ -311,22 +311,22 @@ namespace parse
// Save the current state
states.push(YY_CURRENT_BUFFER);
-
+
yy_flex_debug = trace_p;
if (filename == \"-\")
yyin = stdin;
else
{
- yyin = fopen (filename.c_str (), \"r\");
- if (!yyin)
- {
- std::cerr
- << program_name
- << \": cannot open `\" << filename << \"':
\"
- << strerror (errno) << std::endl;
- exit (1);
- }
+ yyin = fopen (filename.c_str (), \"r\");
+ if (!yyin)
+ {
+ std::cerr
+ << program_name
+ << \": cannot open `\" << filename <<
\"': \"
+ << strerror (errno) << std::endl;
+ exit (1);
+ }
}
yy_switch_to_buffer(yy_create_buffer (yyin, YY_BUF_SIZE));
@@ -336,7 +336,7 @@ namespace parse
scan_close (void)
{
fclose (yyin);
-
+
// Restore the current scanning state.
assertion(!states.empty());
yy_delete_buffer(YY_CURRENT_BUFFER);
--
1.7.2.5