aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlua/rebol.lua
diff options
context:
space:
mode:
authormitchell <unknown>2018-03-11 23:04:41 -0400
committermitchell <unknown>2018-03-11 23:04:41 -0400
commit519b7328b66c4c84f03893a31e4be5ba6b1395f2 (patch)
tree2055cd79006357e94c185f341d0df17b9a8769eb /lexlua/rebol.lua
parentc0373e036e965a70045971e2abc582cb4bf12a4e (diff)
downloadscintilla-mirror-519b7328b66c4c84f03893a31e4be5ba6b1395f2.tar.gz
Added optional Lua lexer support.
This support is disabled by default and must be enabled via compile-time option.
Diffstat (limited to 'lexlua/rebol.lua')
-rw-r--r--lexlua/rebol.lua98
1 files changed, 98 insertions, 0 deletions
diff --git a/lexlua/rebol.lua b/lexlua/rebol.lua
new file mode 100644
index 000000000..a6fc68e93
--- /dev/null
+++ b/lexlua/rebol.lua
@@ -0,0 +1,98 @@
+-- Copyright 2006-2018 Mitchell mitchell.att.foicica.com. See License.txt.
+-- Rebol LPeg lexer.
+
+local lexer = require('lexer')
+local token, word_match = lexer.token, lexer.word_match
+local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+local lex = lexer.new('rebol')
+
+-- Whitespace.
+lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
+
+-- Comments.
+local line_comment = ';' * lexer.nonnewline^0;
+local block_comment = 'comment' * P(' ')^-1 *
+ lexer.delimited_range('{}', false, true)
+lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment))
+
+-- Keywords.
+lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[
+ abs absolute add and~ at back change clear complement copy cp divide fifth
+ find first fourth head insert last make max maximum min minimum multiply
+ negate next or~ pick poke power random remainder remove second select skip
+ sort subtract tail third to trim xor~
+ alias all any arccosine arcsine arctangent bind break browse call
+ caret-to-offset catch checksum close comment compose compress cosine debase
+ decompress dehex detab dh-compute-key dh-generate-key dh-make-key difference
+ disarm do dsa-generate-key dsa-make-key dsa-make-signature
+ dsa-verify-signature either else enbase entab exclude exit exp foreach form
+ free get get-modes halt hide if in intersect load log-10 log-2 log-e loop
+ lowercase maximum-of minimum-of mold not now offset-to-caret open parse prin
+ print protect q query quit read read-io recycle reduce repeat return reverse
+ rsa-encrypt rsa-generate-key rsa-make-key save secure set set-modes show sine
+ size-text square-root tangent textinfo throw to-hex to-local-file
+ to-rebol-file trace try union unique unprotect unset until update uppercase
+ use wait while write write-io
+ basic-syntax-header crlf font-fixed font-sans-serif font-serif list-words
+ outstr val value
+ about alert alter append array ask boot-prefs build-tag center-face change-dir
+ charset choose clean-path clear-fields confine confirm context cvs-date
+ cvs-version decode-cgi decode-url deflag-face delete demo desktop dirize
+ dispatch do-boot do-events do-face do-face-alt does dump-face dump-pane echo
+ editor emailer emit extract find-by-type find-key-face find-window flag-face
+ flash focus for forall forever forskip func function get-net-info get-style
+ has help hide-popup import-email inform input insert-event-func join launch
+ launch-thru layout license list-dir load-image load-prefs load-thru make-dir
+ make-face net-error open-events parse-email-addrs parse-header
+ parse-header-date parse-xml path-thru probe protect-system read-net read-thru
+ reboot reform rejoin remold remove-event-func rename repend replace request
+ request-color request-date request-download request-file request-list
+ request-pass request-text resend save-prefs save-user scroll-para send
+ set-font set-net set-para set-style set-user set-user-name show-popup source
+ split-path stylize switch throw-on-error to-binary to-bitset to-block to-char
+ to-date to-decimal to-email to-event to-file to-get-word to-hash to-idate
+ to-image to-integer to-issue to-list to-lit-path to-lit-word to-logic to-money
+ to-none to-pair to-paren to-path to-refinement to-set-path to-set-word
+ to-string to-tag to-time to-tuple to-url to-word unfocus uninstall unview
+ upgrade Usage vbug view view-install view-prefs what what-dir write-user
+ return at space pad across below origin guide tabs indent style styles size
+ sense backcolor do none
+ action? any-block? any-function? any-string? any-type? any-word? binary?
+ bitset? block? char? datatype? date? decimal? email? empty? equal? error?
+ even? event? file? function? get-word? greater-or-equal? greater? hash? head?
+ image? index? integer? issue? length? lesser-or-equal? lesser? library? list?
+ lit-path? lit-word? logic? money? native? negative? none? not-equal? number?
+ object? odd? op? pair? paren? path? port? positive? refinement? routine? same?
+ series? set-path? set-word? strict-equal? strict-not-equal? string? struct?
+ tag? tail? time? tuple? unset? url? word? zero? connected? crypt-strength?
+ exists-key? input? script? type? value? ? ?? dir? exists-thru? exists?
+ flag-face? found? in-window? info? inside? link-app? link? modified? offset?
+ outside? screen-offset? size? span? view? viewed? win-offset? within?
+ action! any-block! any-function! any-string! any-type! any-word! binary!
+ bitset! block! char! datatype! date! decimal! email! error! event! file!
+ function! get-word! hash! image! integer! issue! library! list! lit-path!
+ lit-word! logic! money! native! none! number! object! op! pair! paren! path!
+ port! refinement! routine! series! set-path! set-word! string! struct! symbol!
+ tag! time! tuple! unset! url! word!
+ true false self
+]]))
+
+-- Identifiers.
+lex:add_rule('identifier', token(lexer.IDENTIFIER, (lexer.alpha + '-') *
+ (lexer.alnum + '-')^0))
+
+-- Strings.
+lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true) +
+ lexer.delimited_range('{}') +
+ "'" * lexer.word))
+
+-- Operators.
+lex:add_rule('operator', token(lexer.OPERATOR, S('=<>+/*:()[]')))
+
+-- Fold points.
+lex:add_fold_point(lexer.COMMENT, '{', '}')
+lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';'))
+lex:add_fold_point(lexer.OPERATOR, '[', ']')
+
+return lex