qse/lib/awk/awk.txt

72 lines
1.2 KiB
Plaintext
Raw Normal View History

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)
global x;
global x, y;
2008-12-21 21:35:07 +00:00
local variables (enabled when awk->opt & QSE_AWK_OPT_VARDCL)
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)
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)
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