diff options
author | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
---|---|---|
committer | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
commit | 519b7328b66c4c84f03893a31e4be5ba6b1395f2 (patch) | |
tree | 2055cd79006357e94c185f341d0df17b9a8769eb /lexlua/powershell.lua | |
parent | c0373e036e965a70045971e2abc582cb4bf12a4e (diff) | |
download | scintilla-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/powershell.lua')
-rw-r--r-- | lexlua/powershell.lua | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lexlua/powershell.lua b/lexlua/powershell.lua new file mode 100644 index 000000000..17bf988fc --- /dev/null +++ b/lexlua/powershell.lua @@ -0,0 +1,63 @@ +-- Copyright 2015-2018 Mitchell mitchell.att.foicica.com. See License.txt. +-- PowerShell LPeg lexer. +-- Contributed by Jeff Stone. + +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('powershell') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + Begin Break Continue Do Else End Exit For ForEach ForEach-Object Get-Date + Get-Random If Param Pause Powershell Process Read-Host Return Switch While + Write-Host +]], true))) + +-- Comparison Operators. +lex:add_rule('comparison', token(lexer.KEYWORD, '-' * word_match([[ + and as band bor contains eq ge gt is isnot le like lt match ne nomatch not + notcontains notlike or replace +]], true))) + +-- Parameters. +lex:add_rule('parameter', token(lexer.KEYWORD, '-' * word_match([[ + Confirm Debug ErrorAction ErrorVariable OutBuffer OutVariable Verbose WhatIf +]], true))) + +-- Properties. +lex:add_rule('property', token(lexer.KEYWORD, '.' * word_match([[ + day dayofweek dayofyear hour millisecond minute month second timeofday year +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.KEYWORD, '[' * word_match([[ + array boolean byte char datetime decimal double hashtable int long single + string xml +]], true) * ']')) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, + '$' * (lexer.digit^1 + lexer.word + + lexer.delimited_range('{}', true, true)))) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/*^&|~.,:;?()[]{}%`'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex |