Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

enable SP as an alias for R7

  • Loading branch information...
commit b9d96a8e8418989e2e344b3605d92b3529ae2263 1 parent dc96b26
@izuzak authored
Showing with 55 additions and 12 deletions.
  1. +4 −1 ace-mode-frisc.js
  2. +45 −9 friscasm.js
  3. +6 −2 friscasm.pegjs
View
5 ace-mode-frisc.js
@@ -55,7 +55,10 @@ define('ace/mode/frisc', function(require, exports, module) {
regex : "^[a-zA-Z][0-9a-zA-Z_]*"
}, {
token : "frisc_register",
- regex : "\\b[Rr][0-7]\\b"
+ regex : "\\s?\\b[Rr][0-7]\\b"
+ }, {
+ token : "frisc_register",
+ regex : "\\s?\\b[sS][pP]\\b"
}, {
token : "frisc_register",
regex : "\\s?\\b[Ss][Rr]\\b"
View
54 friscasm.js
@@ -2803,7 +2803,6 @@ var frisc_asm = (function(){
var pos0, pos1;
pos0 = pos;
- pos1 = pos;
if (/^[rR]/.test(input.charAt(pos))) {
result0 = input.charAt(pos);
pos++;
@@ -2827,19 +2826,56 @@ var frisc_asm = (function(){
result0 = [result0, result1];
} else {
result0 = null;
- pos = pos1;
+ pos = pos0;
}
} else {
result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, regnum) {
- return parseInt(regnum, 10);
- })(pos0, result0[1]);
+ pos = pos0;
}
if (result0 === null) {
- pos = pos0;
+ pos0 = pos;
+ pos1 = pos;
+ if (/^[sS]/.test(input.charAt(pos))) {
+ result0 = input.charAt(pos);
+ pos++;
+ } else {
+ result0 = null;
+ if (reportFailures === 0) {
+ matchFailed("[sS]");
+ }
+ }
+ if (result0 !== null) {
+ if (/^[pP]/.test(input.charAt(pos))) {
+ result1 = input.charAt(pos);
+ pos++;
+ } else {
+ result1 = null;
+ if (reportFailures === 0) {
+ matchFailed("[pP]");
+ }
+ }
+ if (result1 !== null) {
+ result0 = [result0, result1];
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ if (result0 !== null) {
+ result0 = (function(offset) {
+ if (typeof regnum === 'undefined') {
+ return 7; // SP == R7
+ } else {
+ return parseInt(regnum, 10);
+ }
+ })(pos0);
+ }
+ if (result0 === null) {
+ pos = pos0;
+ }
}
return result0;
}
View
8 friscasm.pegjs
@@ -601,8 +601,12 @@ whitespace
= " " / "\t"
register
- = [rR]regnum:[0-7] {
- return parseInt(regnum, 10);
+ = [rR]regnum:[0-7] / [sS][pP] {
+ if (typeof regnum === 'undefined') {
+ return 7; // SP == R7
+ } else {
+ return parseInt(regnum, 10);
+ }
}
number
Please sign in to comment.
Something went wrong with that request. Please try again.