Permalink
Browse files

Improved Sh lexer.

  • Loading branch information...
1 parent f4bd744 commit 099582d7de92b8ef214ba26472d76652076844fb @jgm committed Mar 11, 2010
Showing with 7 additions and 21 deletions.
  1. +7 −21 Text/Highlighting/Illuminate/Sh.x
@@ -13,9 +13,7 @@ $symbol = [\~ \! \% \^ \* \( \) \+ \= \[ \] \\ \: \; \, \. \/ \? \& \< \> \| \%]
$hexdigit = [$digit A-F a-f]
@hexnumber = "0x" $hexdigit+
-@number = [\+ \-]? (@hexnumber |
- (($digit* \.)? $digit+ ([eE] [\+\-]? $digit+)?)
- ) u? (("int" ("8"|"16"|"32"|"64")) | L)?
+@number = [\+ \-]? (@hexnumber | (($digit* \.)? $digit+ ([eE] [\+\-]? $digit+)?))
@keyword =("alias"|"bg"|"bind"|"break"|"builtin"|"caller"|"case"|"command"|"compgen"|
"complete"|"continue"|"declare"|"dirs"|"disown"|"do"|"done"|"elif"|"else"|"enable"|
"esac"|"eval"|"exec"|"exit"|"export"|"false"|"fc"|"fg"|"fi"|"for"|"getopts"|"hash"|"help"|
@@ -29,36 +27,24 @@ $hexdigit = [$digit A-F a-f]
tokens :-
-<strsq> {
- \'\'\' { tok String ==> popContext }
- $white+ { tok Whitespace }
-}
-<strdq> {
- \"\"\" { tok String ==> popContext }
- $white+ { tok Whitespace }
-}
<linecomment> {
@alert { tok Alert }
\n { tok Whitespace ==> popContext }
}
-<def> {
- [$alpha \_] $wordchar* { tok Function ==> popContext }
-}
<0> {
\# { tok Comment ==> pushContext (linecomment, Comment) }
"import" / $white { tok Preproc }
@keyword / ~$wordchar { tok Keyword }
@number { tok Number }
- @string { tok String }
\\ [\" \'] { tok Symbol }
- $symbol { tok Symbol }
+ @string { tok String }
"function" $white+ @ident $white* ("()")? { tok Function }
@ident $white* "()" { tok Function }
--- # it is considered a variable if there's a =, which is discarded anyway
- @ident / \= { tok VarId }
- \$\{ [^ $white]+ \} { tok VarId }
- \$ @ident { tok VarId }
- \$ [^ $white]{1} { tok VarId }
+ @ident / \= { tok Variable }
+ \$\{ [^ $white]+ \} { tok Variable }
+ \$ @ident { tok Variable }
+ \$ [\* \? \@ \!] { tok Variable }
+ $symbol { tok Symbol }
[$alpha \_]$wordchar* { tok Plain }
$white+ { tok Whitespace }

0 comments on commit 099582d

Please sign in to comment.