Skip to content

Commit

Permalink
Merge branch 'master' into bash_arithmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 29, 2020
2 parents 2bdb29d + d93c13e commit def5246
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 73 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -20,6 +20,8 @@ Language Improvements:
- enh(bash) default value is another variable (#2439) [Josh Goebel][]
- enh(bash) string nested within string (#2439) [Josh Goebel][]
- enh(bash) Add arithmetic expression support (#2439) [Josh Goebel][]
- fix(javascript) prevent get/set variables conflicting with keywords (#2440) [Josh Goebel][]
- bug(clojure) Now highlights `defn-` properly (#2438) [Josh Goebel][]
- enh(clojure) Add support for global definitions name (#2347) [Alexandre Grison][]
- enh(fortran) Support Fortran 77 style comments (#2416) [Josh Goebel][]
- (csharp) add support for `@identifier` style identifiers (#2414) [Josh Goebel][]
Expand Down
2 changes: 1 addition & 1 deletion src/languages/arduino.js
Expand Up @@ -12,7 +12,7 @@ export default function(hljs) {
keyword:
'boolean byte word String',
built_in:
'setup loop' +
'setup loop ' +
'KeyboardController MouseController SoftwareSerial ' +
'EthernetServer EthernetClient LiquidCrystal ' +
'RobotControl GSMVoiceCall EthernetUDP EsploraTFT ' +
Expand Down
2 changes: 1 addition & 1 deletion src/languages/c-like.js
Expand Up @@ -93,7 +93,7 @@ export default function(hljs) {
keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' +
'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace ' +
'unsigned long volatile static protected bool template mutable if public friend ' +
'do goto auto void enum else break extern using asm case typeid wchar_t' +
'do goto auto void enum else break extern using asm case typeid wchar_t ' +
'short reinterpret_cast|10 default double register explicit signed typename try this ' +
'switch continue inline delete alignas alignof constexpr consteval constinit decltype ' +
'concept co_await co_return co_yield requires ' +
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ceylon.js
Expand Up @@ -12,7 +12,7 @@ export default function(hljs) {
'catch finally then let this outer super is exists nonempty';
// 7.4.1 Declaration Modifiers
var DECLARATION_MODIFIERS =
'shared abstract formal default actual variable late native deprecated' +
'shared abstract formal default actual variable late native deprecated ' +
'final sealed annotation suppressWarnings small';
// 7.4.2 Documentation
var DOCUMENTATION =
Expand Down
1 change: 1 addition & 0 deletions src/languages/clojure.js
Expand Up @@ -94,6 +94,7 @@ export default function(hljs) {

var GLOBAL = {
beginKeywords: globals,
lexemes: SYMBOL_RE,
end: '(\\[|\\#|\\d|"|:|\\{|\\)|\\(|$)',
contains: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/languages/coq.js
Expand Up @@ -16,7 +16,7 @@ export default function(hljs) {
'Backtrack Bind Blacklist Canonical Cd Check Class Classes Close Coercion ' +
'Coercions CoFixpoint CoInductive Collection Combined Compute Conjecture ' +
'Conjectures Constant constr Constraint Constructors Context Corollary ' +
'CreateHintDb Cut Declare Defined Definition Delimit Dependencies Dependent' +
'CreateHintDb Cut Declare Defined Definition Delimit Dependencies Dependent ' +
'Derive Drop eauto End Equality Eval Example Existential Existentials ' +
'Existing Export exporting Extern Extract Extraction Fact Field Fields File ' +
'Fixpoint Focus for From Function Functional Generalizable Global Goal Grab ' +
Expand Down
6 changes: 3 additions & 3 deletions src/languages/csp.js
Expand Up @@ -13,9 +13,9 @@ export default function(hljs) {
case_insensitive: false,
lexemes: '[a-zA-Z][a-zA-Z0-9_-]*',
keywords: {
keyword: 'base-uri child-src connect-src default-src font-src form-action' +
' frame-ancestors frame-src img-src media-src object-src plugin-types' +
' report-uri sandbox script-src style-src',
keyword: 'base-uri child-src connect-src default-src font-src form-action ' +
'frame-ancestors frame-src img-src media-src object-src plugin-types ' +
'report-uri sandbox script-src style-src',
},
contains: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/languages/dos.js
Expand Up @@ -32,7 +32,7 @@ export default function(hljs) {
'append assoc at attrib break cacls cd chcp chdir chkdsk chkntfs cls cmd color ' +
'comp compact convert date dir diskcomp diskcopy doskey erase fs ' +
'find findstr format ftype graftabl help keyb label md mkdir mode more move path ' +
'pause print popd pushd promt rd recover rem rename replace restore rmdir shift' +
'pause print popd pushd promt rd recover rem rename replace restore rmdir shift ' +
'sort start subst time title tree type ver verify vol ' +
// winutils
'ping net ipconfig taskkill xcopy ren del'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/glsl.js
Expand Up @@ -28,7 +28,7 @@ export default function(hljs) {
type:
'atomic_uint bool bvec2 bvec3 bvec4 dmat2 dmat2x2 dmat2x3 dmat2x4 dmat3 dmat3x2 dmat3x3 ' +
'dmat3x4 dmat4 dmat4x2 dmat4x3 dmat4x4 double dvec2 dvec3 dvec4 float iimage1D iimage1DArray ' +
'iimage2D iimage2DArray iimage2DMS iimage2DMSArray iimage2DRect iimage3D iimageBuffer' +
'iimage2D iimage2DArray iimage2DMS iimage2DMSArray iimage2DRect iimage3D iimageBuffer ' +
'iimageCube iimageCubeArray image1D image1DArray image2D image2DArray image2DMS image2DMSArray ' +
'image2DRect image3D imageBuffer imageCube imageCubeArray int isampler1D isampler1DArray ' +
'isampler2D isampler2DArray isampler2DMS isampler2DMSArray isampler2DRect isampler3D ' +
Expand Down
2 changes: 1 addition & 1 deletion src/languages/irpf90.js
Expand Up @@ -50,7 +50,7 @@ export default function(hljs) {
'set_exponent shape size spacing spread sum system_clock tiny transpose trim ubound unpack verify achar iachar transfer ' +
'dble entry dprod cpu_time command_argument_count get_command get_command_argument get_environment_variable is_iostat_end ' +
'ieee_arithmetic ieee_support_underflow_control ieee_get_underflow_mode ieee_set_underflow_mode ' +
'is_iostat_eor move_alloc new_line selected_char_kind same_type_as extends_type_of' +
'is_iostat_eor move_alloc new_line selected_char_kind same_type_as extends_type_of ' +
'acosh asinh atanh bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn erf erfc erfc_scaled gamma log_gamma hypot norm2 ' +
'atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits ' +
'bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr ' +
Expand Down
28 changes: 20 additions & 8 deletions src/languages/javascript.js
Expand Up @@ -93,6 +93,13 @@ export default function(hljs) {
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]);
var PARAMS = {
className: 'params',
begin: /\(/, end: /\)/,
excludeBegin: true,
excludeEnd: true,
contains: PARAMS_CONTAINS
};

return {
name: 'JavaScript',
Expand Down Expand Up @@ -220,13 +227,7 @@ export default function(hljs) {
beginKeywords: 'function', end: /\{/, excludeEnd: true,
contains: [
hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE}),
{
className: 'params',
begin: /\(/, end: /\)/,
excludeBegin: true,
excludeEnd: true,
contains: PARAMS_CONTAINS
}
PARAMS
],
illegal: /\[|%/
},
Expand All @@ -245,7 +246,18 @@ export default function(hljs) {
]
},
{
beginKeywords: 'constructor get set', end: /\{/, excludeEnd: true
beginKeywords: 'constructor', end: /\{/, excludeEnd: true
},
{
begin:'(get|set)\\s*(?=' + IDENT_RE+ '\\()',
end: /{/,
keywords: "get set",
contains: [
hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE}),
{ begin: /\(\)/ }, // eat to avoid empty params
PARAMS
]

}
],
illegal: /#(?!!)/
Expand Down
6 changes: 3 additions & 3 deletions src/languages/lua.js
Expand Up @@ -35,9 +35,9 @@ export default function(hljs) {
'_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len ' +
'__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert ' +
//Standard methods and properties:
'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring' +
'module next pairs pcall print rawequal rawget rawset require select setfenv' +
'setmetatable tonumber tostring type unpack xpcall arg self' +
'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring ' +
'module next pairs pcall print rawequal rawget rawset require select setfenv ' +
'setmetatable tonumber tostring type unpack xpcall arg self ' +
//Library methods and properties (one line per library):
'coroutine resume yield status wrap create running debug getupvalue ' +
'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv ' +
Expand Down
50 changes: 25 additions & 25 deletions src/languages/mathematica.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/languages/perl.js
Expand Up @@ -8,9 +8,9 @@ Category: common
export default function(hljs) {
var PERL_KEYWORDS = 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq' +
'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq ' +
'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget' +
'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget ' +
'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
Expand All @@ -22,7 +22,7 @@ export default function(hljs) {
'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir' +
'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir ' +
'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when';
var SUBST = {
Expand Down
30 changes: 15 additions & 15 deletions src/languages/pf.js
Expand Up @@ -30,21 +30,21 @@ export default function(hljs) {
*/
'block match pass load anchor|5 antispoof|10 set table',
keyword:
'in out log quick on rdomain inet inet6 proto from port os to route' +
'allow-opts divert-packet divert-reply divert-to flags group icmp-type' +
'icmp6-type label once probability recieved-on rtable prio queue' +
'tos tag tagged user keep fragment for os drop' +
'af-to|10 binat-to|10 nat-to|10 rdr-to|10 bitmask least-stats random round-robin' +
'source-hash static-port' +
'dup-to reply-to route-to' +
'parent bandwidth default min max qlimit' +
'block-policy debug fingerprints hostid limit loginterface optimization' +
'reassemble ruleset-optimization basic none profile skip state-defaults' +
'state-policy timeout' +
'const counters persist' +
'no modulate synproxy state|5 floating if-bound no-sync pflow|10 sloppy' +
'source-track global rule max-src-nodes max-src-states max-src-conn' +
'max-src-conn-rate overload flush' +
'in out log quick on rdomain inet inet6 proto from port os to route ' +
'allow-opts divert-packet divert-reply divert-to flags group icmp-type ' +
'icmp6-type label once probability recieved-on rtable prio queue ' +
'tos tag tagged user keep fragment for os drop ' +
'af-to|10 binat-to|10 nat-to|10 rdr-to|10 bitmask least-stats random round-robin ' +
'source-hash static-port ' +
'dup-to reply-to route-to ' +
'parent bandwidth default min max qlimit ' +
'block-policy debug fingerprints hostid limit loginterface optimization ' +
'reassemble ruleset-optimization basic none profile skip state-defaults ' +
'state-policy timeout ' +
'const counters persist ' +
'no modulate synproxy state|5 floating if-bound no-sync pflow|10 sloppy ' +
'source-track global rule max-src-nodes max-src-states max-src-conn ' +
'max-src-conn-rate overload flush ' +
'scrub|5 max-mss min-ttl no-df|10 random-id',
literal:
'all any no-route self urpf-failed egress|5 unknown'
Expand Down
4 changes: 2 additions & 2 deletions src/languages/pgsql.js
Expand Up @@ -210,7 +210,7 @@ export default function(hljs) {
'ACOS ACOSD ASIN ASIND ATAN ATAND ATAN2 ATAN2D COS COSD COT COTD SIN SIND TAN TAND ' +
// https://www.postgresql.org/docs/11/static/functions-string.html
'BIT_LENGTH CHAR_LENGTH CHARACTER_LENGTH LOWER OCTET_LENGTH OVERLAY POSITION SUBSTRING TREAT TRIM UPPER ' +
'ASCII BTRIM CHR CONCAT CONCAT_WS CONVERT CONVERT_FROM CONVERT_TO DECODE ENCODE INITCAP' +
'ASCII BTRIM CHR CONCAT CONCAT_WS CONVERT CONVERT_FROM CONVERT_TO DECODE ENCODE INITCAP ' +
'LEFT LENGTH LPAD LTRIM MD5 PARSE_IDENT PG_CLIENT_ENCODING QUOTE_IDENT|10 QUOTE_LITERAL|10 ' +
'QUOTE_NULLABLE|10 REGEXP_MATCH REGEXP_MATCHES REGEXP_REPLACE REGEXP_SPLIT_TO_ARRAY ' +
'REGEXP_SPLIT_TO_TABLE REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPLIT_PART STRPOS SUBSTR ' +
Expand All @@ -229,7 +229,7 @@ export default function(hljs) {
'AREA CENTER DIAMETER HEIGHT ISCLOSED ISOPEN NPOINTS PCLOSE POPEN RADIUS WIDTH ' +
'BOX BOUND_BOX CIRCLE LINE LSEG PATH POLYGON ' +
// https://www.postgresql.org/docs/11/static/functions-net.html
'ABBREV BROADCAST HOST HOSTMASK MASKLEN NETMASK NETWORK SET_MASKLEN TEXT INET_SAME_FAMILY' +
'ABBREV BROADCAST HOST HOSTMASK MASKLEN NETMASK NETWORK SET_MASKLEN TEXT INET_SAME_FAMILY ' +
'INET_MERGE MACADDR8_SET7BIT ' +
// https://www.postgresql.org/docs/11/static/functions-textsearch.html
'ARRAY_TO_TSVECTOR GET_CURRENT_TS_CONFIG NUMNODE PLAINTO_TSQUERY PHRASETO_TSQUERY WEBSEARCH_TO_TSQUERY ' +
Expand Down
2 changes: 1 addition & 1 deletion src/languages/qml.js
Expand Up @@ -26,7 +26,7 @@ export default function(hljs) {
'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' +
'Behavior bool color coordinate date double enumeration font geocircle georectangle ' +
'geoshape int list matrix4x4 parent point quaternion real rect ' +
'size string url variant vector2d vector3d vector4d' +
'size string url variant vector2d vector3d vector4d ' +
'Promise'
};

Expand Down
6 changes: 3 additions & 3 deletions src/languages/reasonml.js
Expand Up @@ -30,9 +30,9 @@ export default function(hljs) {

var KEYWORDS = {
keyword:
'and as asr assert begin class constraint do done downto else end exception external' +
'for fun function functor if in include inherit initializer' +
'land lazy let lor lsl lsr lxor match method mod module mutable new nonrec' +
'and as asr assert begin class constraint do done downto else end exception external ' +
'for fun function functor if in include inherit initializer ' +
'land lazy let lor lsl lsr lxor match method mod module mutable new nonrec ' +
'object of open or private rec sig struct then to try type val virtual when while with',
built_in:
'array bool bytes char exn|5 float int int32 int64 list lazy_t|5 nativeint|5 ref string unit ',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/stan.js
Expand Up @@ -193,7 +193,7 @@ export default function(hljs) {
{
// hack: in range constraints, upper must follow either , or <
// <lower = ..., upper = ...> or <upper = ...>
begin: /[<,]*upper\s*=/,
begin: /[<,]\s*upper\s*=/,
keywords: 'upper'
},
{
Expand Down
7 changes: 6 additions & 1 deletion src/lib/mode_compiler.js
Expand Up @@ -83,7 +83,12 @@ export function compileLanguage(language) {

if (parent) {
if (mode.beginKeywords) {
mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
// for languages with keywords that include non-word characters checking for
// a word boundary is not sufficient, so instead we check for a word boundary
// or whitespace - this does no harm in any case since our keyword engine
// doesn't allow spaces in keywords anyways and we still check for the boundary
// first
mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?=\\b|\\s)';
}
if (!mode.begin)
mode.begin = /\B|\b/;
Expand Down
2 changes: 1 addition & 1 deletion test/markup/clojure/globals_definition.expect.txt
Expand Up @@ -22,7 +22,7 @@
(<span class="hljs-keyword">defonce</span> ^<span class="hljs-symbol">:private</span> <span class="hljs-title">another-var</span> #<span class="hljs-string">"foo"</span>)

<span class="hljs-comment">; private function</span>
(<span class="hljs-keyword">defn</span><span class="hljs-title">-</span> add [x y] (<span class="hljs-name"><span class="hljs-builtin-name">+</span></span> x y))
(<span class="hljs-keyword">defn-</span> <span class="hljs-title">add</span> [x y] (<span class="hljs-name"><span class="hljs-builtin-name">+</span></span> x y))

<span class="hljs-comment">; protocols</span>
(<span class="hljs-keyword">defprotocol</span> <span class="hljs-title">Fly</span>
Expand Down
9 changes: 9 additions & 0 deletions test/markup/javascript/keyword_as_identifier.expect.txt
@@ -0,0 +1,9 @@
<span class="hljs-keyword">const</span> set = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]);
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> e <span class="hljs-keyword">of</span> set)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">A</span> </span>{
<span class="hljs-keyword">set</span> <span class="hljs-title">value</span>(<span class="hljs-params">x</span>) {
}
<span class="hljs-keyword">get</span> <span class="hljs-title">valid</span>() {
}
}
9 changes: 9 additions & 0 deletions test/markup/javascript/keyword_as_identifier.txt
@@ -0,0 +1,9 @@
const set = new Set([1, 2]);
for (const e of set)

class A {
set value(x) {
}
get valid() {
}
}

0 comments on commit def5246

Please sign in to comment.