Skip to content

Commit

Permalink
[factor mode] Various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimage Sapelkin authored and marijnh committed Apr 26, 2017
1 parent 33068f9 commit 37d59ff
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions mode/factor/factor.js
Expand Up @@ -22,52 +22,54 @@
{regex: /#?!.*/, token: "comment"},
// strings """, multiline --> state
{regex: /"""/, token: "string", next: "string3"},
{regex: /"/, token: "string", next: "string"},
{regex: /(STRING:)(\s)/, token: ["keyword", null], next: "string2"},
{regex: /\S*?"/, token: "string", next: "string"},
// numbers: dec, hex, unicode, bin, fractional, complex
{regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
{regex: /(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\-?\d+.?\d*)(?=\s)/, token: "number"},
//{regex: /[+-]?/} //fractional
// definition: defining word, defined word, etc
{regex: /(\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "keyword"], next: "stack"},
{regex: /((?:GENERIC)|\:?\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "bracket"], next: "stack"},
// method definition: defining word, type, defined word, etc
{regex: /(M\:)(\s+)(\S+)(\s+)(\S+)/, token: ["keyword", null, "def", null, "tag"]},
// vocabulary using --> state
{regex: /USING\:/, token: "keyword", next: "vocabulary"},
// vocabulary definition/use
{regex: /(USE\:|IN\:)(\s+)(\S+)/, token: ["keyword", null, "variable-2"]},
// <constructors>
{regex: /<\S+>/, token: "builtin"},
{regex: /(USE\:|IN\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "tag"]},
// definition: a defining word, defined word
{regex: /(\S+\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "def"]},
// "keywords", incl. ; t f . [ ] { } defining words
{regex: /;|t|f|if|\.|\[|\]|\{|\}|MAIN:/, token: "keyword"},
{regex: /(?:;|\\|t|f|if|loop|while|until|do|PRIVATE>|<PRIVATE|\.|\S*\[|\]|\S*\{|\})(?=\s|$)/, token: "keyword"},
// <constructors> and the like
{regex: /\S+[\)>\.\*\?]+(?=\s|$)/, token: "builtin"},
{regex: /[\)><]+\S+(?=\s|$)/, token: "builtin"},
// operators
{regex: /(?:[\+\-\=\/\*<>])(?=\s|$)/, token: "keyword"},
// any id (?)
{regex: /\S+/, token: "variable"},

{
regex: /./,
token: null
}
{regex: /\s+|./, token: null}
],
vocabulary: [
{regex: /;/, token: "keyword", next: "start"},
{regex: /\S+/, token: "variable-2"},
{
regex: /./,
token: null
}
{regex: /\S+/, token: "tag"},
{regex: /\s+|./, token: null}
],
string: [
{regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},
{regex: /.*/, token: "string"}
],
string2: [
{regex: /^;/, token: "keyword", next: "start"},
{regex: /.*/, token: "string"}
],
string3: [
{regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},
{regex: /.*/, token: "string"}
],
stack: [
{regex: /\)/, token: "meta", next: "start"},
{regex: /--/, token: "meta"},
{regex: /\S+/, token: "variable-3"},
{
regex: /./,
token: null
}
{regex: /\)/, token: "bracket", next: "start"},
{regex: /--/, token: "bracket"},
{regex: /\S+/, token: "meta"},
{regex: /\s+|./, token: null}
],
// The meta property contains global information about the mode. It
// can contain properties like lineComment, which are supported by
Expand Down

0 comments on commit 37d59ff

Please sign in to comment.