-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax Highlighting
Syntax highlighting is fueled by a mode’s keywords.txt file. Possible tokens can be found in Token.java. This page sheds light on how keywords have been created. Currently, this is a manual process, that will be replaced by a proper Gradle task if time permits.
Keyword creation is inspired by the p5.js web editor. Unless otherwise specified, the source for keywords is the p5.js reference JSON. The shell commands to obtain keywords are listed below.
LITERAL2. Keywords are all names of the Constants module.
curl https://p5js.org/reference/data.json | jq -r '.classitems[] | select(.module=="Constants") | .name+" LITERAL2"' | sort | uniqKEYWORD1. Extracted from Codemirror, the editor library that is also used by the p5.js web editor. Please note that this does not include some of the Foundation keywords of p5.js: Number, console, Object, Array, String, Boolean.
KEYWORD3. Manually selected: catch, do, else, for, if, switch, try, while.
KEYWORD2. All reference items with itemtype of property and a class different from p5. Also exclude modules Constants (covered above) and Foundation (JavaScript keywords).
curl https://p5js.org/reference/data.json | jq -r '.classitems[] | select(.module != "Constants" and .module != "Foundation" and .class != "p5" and .itemtype == "property") | .name + " KEYWORD2"' | sort | uniqKEYWORD4. Same as above, but with class equal to p5.
url https://p5js.org/reference/data.json | jq -r '.classitems[] | select(.module != "Constants" and .module != "Foundation" and .class == "p5" and .itemtype == "property") | .name + " KEYWORD4"' | sort | uniqFUNCTION1. All reference items with itemtype of method and class equal to p5.
curl https://p5js.org/reference/data.json | jq -r '.classitems[] | select(.itemtype == "method" and .class == "p5") as $methods | .name + " FUNCTION1"' | sort | uniqFUNCTION2. Same as above, but with a class different from p5.
curl https://p5js.org/reference/data.json | jq -r '.classitems[] | select(.itemtype == "method" and .class != "p5") as $methods | .name + " FUNCTION2"' | sort | uniqFUNCTION3. For example, setup() or mouseDragged(). These functions are not distinguishable from other methods above based only on properties in the reference JSON. Currently, they have to be manually selected. An automated selection could check the examples for a string like function <name>. Will implement if time allows.