2007-05-02 01:07:00 +00:00
|
|
|
Programs
|
|
|
|
|
|
|
|
pattern { action }
|
|
|
|
function name (parameter-list) { statement }
|
|
|
|
|
|
|
|
Patterns
|
|
|
|
BEGIN
|
|
|
|
END
|
|
|
|
expresion
|
|
|
|
/regular expression/
|
|
|
|
pattern && pattern
|
|
|
|
pattern || pattern
|
|
|
|
!pattern
|
|
|
|
(pattern)
|
|
|
|
pattern, pattern -> range pattern
|
|
|
|
|
|
|
|
Actions
|
|
|
|
break
|
|
|
|
continue
|
|
|
|
delete array-element
|
|
|
|
do statement while (expression)
|
|
|
|
exit [expression]
|
|
|
|
expression
|
|
|
|
if (expression) statement [else statement]
|
|
|
|
input-output statement
|
|
|
|
for (expression; expression; expression) statement
|
|
|
|
for (variable in array) statement
|
|
|
|
next
|
|
|
|
return [expression]
|
|
|
|
while (expression) statement
|
|
|
|
{ statements }
|
|
|
|
|
|
|
|
Variables
|
|
|
|
|
2008-12-21 21:35:07 +00:00
|
|
|
global variables (enabled when awk->opt & QSE_AWK_OPT_VARDCL)
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
global x;
|
|
|
|
global x, y;
|
|
|
|
|
2008-12-21 21:35:07 +00:00
|
|
|
local variables (enabled when awk->opt & QSE_AWK_OPT_VARDCL)
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
local x;
|
|
|
|
local x, y;
|
|
|
|
|
|
|
|
function arguments (enabled always)
|
|
|
|
|
|
|
|
function funca (x, y)
|
|
|
|
|
|
|
|
|
2008-12-21 21:35:07 +00:00
|
|
|
local variables in function declaration (enabled when awk->opt & QSE_AWK_OPT_FUNCLOCAL)
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
function funca (x, y, v1, v2)
|
|
|
|
|
|
|
|
|
2008-12-21 21:35:07 +00:00
|
|
|
variables without any declarations (enabled when awk->opt & QSE_AWK_OPT_NAMEDVAR)
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
x = 10; // x is put into the global hash table.
|
|
|
|
|
|
|
|
|
|
|
|
Optimization
|
|
|
|
|
|
|
|
constant folding
|
|
|
|
2 * 10 => 20
|
|
|
|
|
|
|
|
loop
|
|
|
|
remove while (0) { ... }
|
|
|
|
|
|
|
|
if
|
|
|
|
remove if (0) {}
|
|
|
|
use else_part only
|
|
|
|
|