问题描述:

I swear I've done my homework on this

I am trying to add the Lex and Yacc languages to brackets, but after many iterations, can't figure out where I've gone wrong anymore:

I have the brackets.json file:

{

"fonts.fontSize": "13px",

"fonts.fontFamily": "'SourceCodePro-Medium'",

"themes.theme": "deep-ocean",

"useTabChar": true,

"spaceUnits": 2,

"linting.collapsed": true,

"tabSize": 4,

"noDistractions": true,

"uppercaseColors": true,

"language.fileExtensions": {

"l": "Lex",

"y": "Yacc"

}

}


and the file main.js in my themes folder:

define(function (require, exports, module){

"use strict";

//Load Modules

var LanguageManager = brackets.getModule("language/LanguageManager"),

CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"),

LexYaccMode = require("LexYacc");

LanguageManager.defineLanguage("Lex", {

name: "Lex",

mode: "Lex",

fileExtensions: ["l"]

});

LanguageManager.defineLanguage("Yacc", {

name: "Yacc",

mode: "Yacc",

fileExtensions: ["y"]

});

});


and finally, LexYacc.js, for the CodeMirror RegEx:

CodeMirror.defineSimpleMode("Lex", {

start: [

{regex: /"(?:[^\\]|\\.)*?"/, token: "string"},

{regex: /(function)(\s+)([a-z$][\w$]*)/, token: ["keyword", null, "variable-2"]},

{regex: /#include ["<]\w*[">]/, token: "variable-2"},

{regex: /(?:function|var|return|if|for|while|else|do|this)\b/, token: "keyword"},

{regex: /%%|%\{|%\}|true|false|null|undefined/, token: "atom"},

{regex: /0x[a-f\d]+|[\-+]?(?:\.\d+|\d+\.?\d*)(?:e[\-+]?\d+)?/i, token: "number"},

{regex: /\/\/.*/, token: "comment"},

{regex: /yy\w+/, token: "variable-3"},

{regex: /\/\*/, token: "comment", next: "comment"},

{regex: /[\-+\/*=<>!]+/, token: "operator"},

{regex: /[\{\[\(\%{]/, indent: true},

{regex: /[\}\]\)\%}]/, dedent: true},

{regex: /[a-z$][\w$]*/, token: "variable"}

],

comment: [

{regex: /.*?\*\//, token: "comment", next: "start"},

{regex: /.*/, token: "comment"}

]

});

CodeMirror.defineSimpleMode("Yacc", {

start: [

{regex: /"(?:[^\\]|\\.)*?"/, token: "string"},

{regex: /(function)(\s+)([a-z$][\w$]*)/, token: ["keyword", null, "variable-2"]},

{regex: /#include ["<]\w*[">]/, token: "variable-2"},

{regex: /(?:function|var|return|if|for|while|else|do|this)\b/, token: "keyword"},

{regex: /%%|%\{|%\}|true|false|null|undefined/, token: "atom"},

{regex: /0x[a-f\d]+|[\-+]?(?:\.\d+|\d+\.?\d*)(?:e[\-+]?\d+)?/i, token: "number"},

{regex: /\/\/.*/, token: "comment"},

{regex: /yy\w+/, token: "variable-3"},

{regex: /\/\*/, token: "comment", next: "comment"},

{regex: /[\-+\/*=<>!]+/, token: "operator"},

{regex: /[\{\[\(\%{]/, indent: true},

{regex: /[\}\]\)\%}]/, dedent: true},

{regex: /[a-z$][\w$]*/, token: "variable"}

],

comment: [

{regex: /.*?\*\//, token: "comment", next: "start"},

{regex: /.*/, token: "comment"}

]

});


At this point, I have tried everything I know how, but I can't figure out why the RegEx expressions aren't taking effect, and why Brackets isn't giving Lex or Yacc on the language menu.

相关阅读:
Top