Skip to content
Browse files

Merge pull request #14 from krasin/13-ignore-dot-directives

Fix #13: ignore [dot]directives, like .size, .data, .text, etc

Nice - this is quite concise and a great way of adding support to the assembler. I'll just make a couple of modifications after commit.
  • Loading branch information...
2 parents f2cfa6e + eb4f14c commit 9a28af1f9149dba65124ffdca460354d94359f7c @dwilliamson committed Apr 13, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 dcpu.js
View
9 dcpu.js
@@ -148,6 +148,7 @@ var dcpuTokens = {
// Keywords/text
INSTRUCTION:"INSTRUCTION",
REGISTER:"REGISTER",
+ DOTDIRECTIVE:"DOT DIRECTIVE",
LABEL:"LABEL",
// Values
@@ -268,6 +269,9 @@ function dcpuLexer(report)
return [ dcpuTokens.INSTRUCTION, dcpuOpcodes[text] ];
if (text in dcpuRegisters)
return [ dcpuTokens.REGISTER, dcpuRegisters[text] ];
+ if (text != "" && text[0] == '.') {
+ return [ dcpuTokens.DOTDIRECTIVE, text ];
+ }
return [ dcpuTokens.LABEL, text ];
}
@@ -610,6 +614,11 @@ function dcpuAssembler(report)
case (dcpuTokens.END):
continue;
+ // Skip .size, .text, .data, etc directives
+ case (dcpuTokens.DOTDIRECTIVE):
+ continue;
+
+
// Only accept labels and instructions
case (dcpuTokens.COLON):
this.ParseLabel();

0 comments on commit 9a28af1

Please sign in to comment.
Something went wrong with that request. Please try again.