diff --git a/autotests/folding/highlight.awk.fold b/autotests/folding/highlight.awk.fold --- a/autotests/folding/highlight.awk.fold +++ b/autotests/folding/highlight.awk.fold @@ -26,3 +26,27 @@ END { print p; } + +function myfunc() +{ + print 42 +} + +/abc/,/a[b]c/{ + # parameter with a regex + if (match($0, /a/)) {} + + "x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x" + + a =~ /[[:alpha:]]/ + a =~ /[xx[:alpha:]xx]/ + a =~ /[a-z[:alpha:]xx-]/ + a =~ /[]a]/ + a =~ /[-a]/ + a =~ /[^]a]/ + a =~ /[^-a]/ + a =~ /[a]a\/\n/ + # incomplete regex + a =~ /[xx[:alph + a = 23.2 +} diff --git a/autotests/html/highlight.awk.html b/autotests/html/highlight.awk.html --- a/autotests/html/highlight.awk.html +++ b/autotests/html/highlight.awk.html @@ -8,28 +8,52 @@ # AWK hl test # BEGIN and END are also matched as patterns -BEGIN { +BEGIN { p = 0; -} +} -/some pattern/ { +/some pattern/ { p++; -} +} # / inside brackets is not considered end of expression # a loose division operator (/) is not mismatched as a pattern. -$1 =~ /[^abc/]def/ || b == 3 / 5 { +$1 =~ /[^abc/]def/ || b == 3 / 5 { gsub ( FILENAME ); -} +} # TODO and FIXME also work in comments in Awk. # Also backslash in patterns works. -/\/usr\/bin\/awk/ { print "This is me"; } +/\/usr\/bin\/awk/ { print "This is me"; } -END { +END { print p; -} +} + +function myfunc() +{ + print 42 +} + +/abc/,/a[b]c/{ + # parameter with a regex + if (match($0, /a/)) {} + + "x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x" + + a =~ /[[:alpha:]]/ + a =~ /[xx[:alpha:]xx]/ + a =~ /[a-z[:alpha:]xx-]/ + a =~ /[]a]/ + a =~ /[-a]/ + a =~ /[^]a]/ + a =~ /[^-a]/ + a =~ /[a]a\/\n/ + # incomplete regex + a =~ /[xx[:alph + a = 23.2 +} diff --git a/autotests/input/highlight.awk b/autotests/input/highlight.awk --- a/autotests/input/highlight.awk +++ b/autotests/input/highlight.awk @@ -26,3 +26,27 @@ END { print p; } + +function myfunc() +{ + print 42 +} + +/abc/,/a[b]c/{ + # parameter with a regex + if (match($0, /a/)) {} + + "x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x" + + a =~ /[[:alpha:]]/ + a =~ /[xx[:alpha:]xx]/ + a =~ /[a-z[:alpha:]xx-]/ + a =~ /[]a]/ + a =~ /[-a]/ + a =~ /[^]a]/ + a =~ /[^-a]/ + a =~ /[a]a\/\n/ + # incomplete regex + a =~ /[xx[:alph + a = 23.2 +} diff --git a/autotests/reference/highlight.awk.ref b/autotests/reference/highlight.awk.ref --- a/autotests/reference/highlight.awk.ref +++ b/autotests/reference/highlight.awk.ref @@ -2,27 +2,51 @@ # AWK hl test

# BEGIN and END are also matched as patterns
-BEGIN {
- p = 0;
-}
+BEGIN {
+ p = 0;
+}

-/some pattern/ {
- p++;
-}
+/some pattern/ {
+ p++;
+}

# / inside brackets is not considered end of expression
# a loose division operator (/) is not mismatched as a pattern.
-$1 =~ /[^abc/]def/ || b == 3 / 5 {
+$1 =~ /[^abc/]def/ || b == 3 / 5 {

- gsub ( FILENAME );
+ gsub ( FILENAME );

-}
+}

# TODO and FIXME also work in comments in Awk.

# Also backslash in patterns works.
-/\/usr\/bin\/awk/ { print "This is me"; }
-
-END {
- print p;
-}
+/\/usr\/bin\/awk/ { print "This is me"; }
+
+END {
+ print p;
+}
+
+function myfunc()
+{
+ print 42
+}
+
+/abc/,/a[b]c/{
+ # parameter with a regex
+ if (match($0, /a/)) {}
+
+ "x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x"
+
+ a =~ /[[:alpha:]]/
+ a =~ /[xx[:alpha:]xx]/
+ a =~ /[a-z[:alpha:]xx-]/
+ a =~ /[]a]/
+ a =~ /[-a]/
+ a =~ /[^]a]/
+ a =~ /[^-a]/
+ a =~ /[a]a\/\n/
+ # incomplete regex
+ a =~ /[xx[:alph
+ a = 23.2
+}
diff --git a/data/syntax/awk.xml b/data/syntax/awk.xml --- a/data/syntax/awk.xml +++ b/data/syntax/awk.xml @@ -1,217 +1,267 @@ - - + if else while do for - in - continue break + continue + return + switch + case + default + exit + + + in + delete print printf getline function - return next nextfile - exit - switch - case - default @include @load ARGC + ARGIND ARGV + BINMODE CONVFMT ENVIRON ERRNO + FIELDWIDTHS FILENAME FNR FPAT FS FUNCTAB IGNORECASE + LINT NF NR OFMT OFS ORS + PREC PROCINFO + ROUNDMODE RS + RT RSTART RLENGTH SUBSEP SYMTAB + TEXTDOMAIN + + close + fflush + system + + atan2 + cos + exp + int + log + rand + sin + sqrt + srand + asort asorti - gsub gensub + gsub index - isarray length - lshift match - mktime patsplit - rshift split sprintf - sround - strftime strtonum sub substr - systime tolower toupper - typeof + + mktime + strftime + systime + + and + compl + lshift + or + rshift xor - atan2 - cos - exp - int - log - rand - sin - sqrt - srand - close - fflush - system + + isarray + typeof + + bindtextdomain + dcgettext + dcngettext BEGIN BEGINFILE END ENDFILE + + alpha + alnum + blank + cntrl + digit + graph + lower + print + punct + space + upper + xdigit + - + + - + - - + + + - - - - - + + + + + + + + + + + + + - - + - - + + + - - + - + + - + + - - - + + + + - - - + + + + - + - - - - - - - - - + + + - - - + + + + + + - - + + + + + - - - + + + + - - - + + + + - - - + + + + @@ -221,16 +271,18 @@ - + + + - - + + - +