Added sendpraat and unquoted string directives, simplified demo example, added some other missing functions/directives
This commit is contained in:
parent
a519520ae7
commit
17c75da27b
4 changed files with 81 additions and 30 deletions
|
|
@ -113,7 +113,7 @@ var supportedModes = {
|
|||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|phtml"],
|
||||
Powershell: ["ps1"],
|
||||
Praat: ["praat"],
|
||||
Praat: ["praat|praatscript|psc|proc"],
|
||||
Prolog: ["plg|prolog"],
|
||||
Properties: ["properties"],
|
||||
Protobuf: ["proto"],
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ var Mode = function() {
|
|||
this.HighlightRules = PraatHighlightRules;
|
||||
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"});
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ var PraatHighlightRules = function() {
|
|||
|
||||
var keywords = (
|
||||
"if|then|else|elsif|elif|endif|fi|" +
|
||||
"endfor|endproc|" + // other for-related keywords are specified below
|
||||
"endfor|endproc|" + // related keywords specified below
|
||||
"while|endwhile|" +
|
||||
"repeat|until|" +
|
||||
"select|plus|minus|" +
|
||||
|
|
@ -24,10 +24,16 @@ var PraatHighlightRules = function() {
|
|||
"temporaryDirectory\\$|defaultDirectory\\$"
|
||||
);
|
||||
|
||||
// What is "endSendPraat"? Function? Directive?
|
||||
var directives = (
|
||||
"clearinfo|endSendPraat"
|
||||
);
|
||||
|
||||
var functions = (
|
||||
// Math functions
|
||||
// Info functions
|
||||
"writeInfo|writeInfoLine|appendInfo|appendInfoLine|" +
|
||||
"writeFile|writeFileLine|appendFile|appendFileLine|" +
|
||||
// Math functions
|
||||
"abs|round|floor|ceiling|min|max|imin|imax|" +
|
||||
"sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" +
|
||||
"exp|ln|log10|log2|" +
|
||||
|
|
@ -45,24 +51,26 @@ var PraatHighlightRules = function() {
|
|||
"phonToDifferenceLimens|differenceLimensToPhon|" +
|
||||
"beta|besselI|besselK|" +
|
||||
// String functions
|
||||
"selected|selected$|numberOfSelected|variableExists|"+
|
||||
"selected|selected\\$|numberOfSelected|variableExists|"+
|
||||
"index|rindex|startsWith|endsWith|"+
|
||||
"index_regex|rindex_regex|replace_regex$|"+
|
||||
"length|extractWord$|extractLine$|extractNumber|" +
|
||||
"left$|right$|mid$|replace$|" +
|
||||
"index_regex|rindex_regex|replace_regex\\$|"+
|
||||
"length|extractWord\\$|extractLine\\$|extractNumber|" +
|
||||
"left\\$|right\\$|mid\\$|replace\\$|" +
|
||||
// Pause functions
|
||||
"beginPause|endPause|" +
|
||||
// Demo functions
|
||||
"demoShow|demoWindowTitle|demoInput|demoWaitForInput|" +
|
||||
"demoClicked|demoClickedIn|demoX|demoY|" +
|
||||
"demoKeyPressed|demoKey$|" +
|
||||
"demoKeyPressed|demoKey\\$|" +
|
||||
"demoExtraControlKeyPressed|demoShiftKeyPressed|"+
|
||||
"demoCommandKeyPressed|demoOptionKeyPressed|" +
|
||||
// File functions
|
||||
"environment$|" +
|
||||
"chooseDirectory$|createDirectory|fileReadable|deleteFile|" +
|
||||
"environment\\$|chooseReadFile\\$|" +
|
||||
"chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" +
|
||||
"selectObject|removeObject|plusObject|minusObject|" +
|
||||
"runScript|exitScript"
|
||||
"runScript|exitScript|" +
|
||||
// sendpraat functions
|
||||
"beginSendPraat|endSendPraat"
|
||||
);
|
||||
|
||||
var objectTypes = (
|
||||
|
|
@ -95,18 +103,35 @@ var PraatHighlightRules = function() {
|
|||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
// stopwatch
|
||||
token : ["text", "text", "keyword.operator", "text", "keyword"],
|
||||
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(stopwatch)/
|
||||
}, {
|
||||
// Directives which introduce unquoted strings
|
||||
token : ["text", "keyword", "text", "string"],
|
||||
regex : /(^\s*)(print(?:line)?|echo|exit|pause|sendpraat|include|execute)(\s+)(.*)/
|
||||
}, {
|
||||
// Directives with no arguments
|
||||
token : ["text", "keyword"],
|
||||
regex : "(^\\s*)(" + directives + ")$"
|
||||
}, {
|
||||
// Operators
|
||||
token : ["text", "keyword.operator", "text"],
|
||||
regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/
|
||||
}, {
|
||||
// Commands
|
||||
token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"],
|
||||
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
|
||||
}, {
|
||||
// Demo commands
|
||||
token : ["text", "keyword", "text", "keyword"],
|
||||
regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
|
||||
}, {
|
||||
// Font-sizing commands
|
||||
token : ["text", "keyword", "text", "keyword"],
|
||||
regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/
|
||||
}, {
|
||||
// do-style command calls
|
||||
token : ["text", "support.function", "text"],
|
||||
regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/
|
||||
}, {
|
||||
|
|
@ -114,53 +139,64 @@ var PraatHighlightRules = function() {
|
|||
// token : ["text", "keyword"],
|
||||
// regex : /(^\s*)(demo\b)/
|
||||
// }, {
|
||||
// Object types
|
||||
token : "entity.name.type",
|
||||
regex : "(" + objectTypes + ")"
|
||||
}, {
|
||||
// Predefined variables
|
||||
token : "variable.language",
|
||||
regex : "(" + predefinedVariables + ")"
|
||||
}, {
|
||||
// Functions
|
||||
token : ["support.function", "text"],
|
||||
regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())"
|
||||
}, {
|
||||
// For-loop declarations
|
||||
token : "keyword",
|
||||
regex : /(\bfor\b)/,
|
||||
next : "for"
|
||||
}, {
|
||||
// Generic keywords
|
||||
token : "keyword",
|
||||
regex : "(\\b(?:" + keywords + ")\\b)"
|
||||
}, {
|
||||
// Interpolated strings
|
||||
token : "string.interpolated",
|
||||
regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/
|
||||
}, {
|
||||
// Generic strings
|
||||
token : "string",
|
||||
regex : /"[^"]*"/
|
||||
}, {
|
||||
// Multiline quoted strings
|
||||
token : "string",
|
||||
regex : /"[^"]*$/,
|
||||
next : "brokenstring"
|
||||
}, {
|
||||
// Form declarations
|
||||
token : ["text", "keyword", "text", "entity.name.section"],
|
||||
regex : /(^\s*)(\bform\b)(\s+)(.*)/,
|
||||
next : "form"
|
||||
}, {
|
||||
// Numeric constants
|
||||
token : "constant.numeric",
|
||||
regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
|
||||
}, {
|
||||
// Procedure declarations
|
||||
token : ["keyword", "text", "entity.name.function"],
|
||||
regex : /(procedure)(\s+)(\S+)/
|
||||
}, {
|
||||
// New-style procedure calls
|
||||
token : ["entity.name.function", "text"],
|
||||
regex : /(@\S+)(:|\s*\()/
|
||||
}, {
|
||||
// Old-style procedure calls
|
||||
token : ["text", "keyword", "text", "entity.name.function"],
|
||||
regex : /(^\s*)(call)(\s+)(\S+)/
|
||||
}, {
|
||||
// Comments
|
||||
token : "comment",
|
||||
regex : ";.*$"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "#.*$"
|
||||
regex : /(^\s*#|;).*$/
|
||||
}, {
|
||||
token : "text",
|
||||
regex : /\s+/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue