From 9f6e54e92820754d4f05e7d6ef556c11c5351411 Mon Sep 17 00:00:00 2001 From: murphy Date: Tue, 20 Oct 2009 11:12:26 +0000 Subject: Updated PHP scanner (#36) * highlighting of class and function definitions * improved HTML/PHP detection * heredocs (simple) * a new test for classes --- test/scanners/php/class.expected.raydebug | 83 ++++++++ test/scanners/php/class.in.php | 83 ++++++++ test/scanners/php/pleac.expected.raydebug | 312 +++++++++++++++--------------- test/scanners/php/test.expected.raydebug | 10 +- 4 files changed, 327 insertions(+), 161 deletions(-) create mode 100644 test/scanners/php/class.expected.raydebug create mode 100644 test/scanners/php/class.in.php (limited to 'test') diff --git a/test/scanners/php/class.expected.raydebug b/test/scanners/php/class.expected.raydebug new file mode 100644 index 0000000..bc46870 --- /dev/null +++ b/test/scanners/php/class.expected.raydebug @@ -0,0 +1,83 @@ +comment() +inline_delimiter()ident(items)operator([)local_variable($artnr)operator(]) operator(+=) local_variable($num)operator(;) + operator(}) + + comment(// Take $num articles of $artnr out of the cart) + + reserved(function) function(remove_item)operator(()local_variable($artnr)operator(,) local_variable($num)operator(\)) operator({) + reserved(if) operator(()local_variable($this)operator(->)ident(items)operator([)local_variable($artnr)operator(]) operator(>) local_variable($num)operator(\)) operator({) + local_variable($this)operator(->)ident(items)operator([)local_variable($artnr)operator(]) operator(-=) local_variable($num)operator(;) + reserved(return) pre_constant(true)operator(;) + operator(}) reserved(elseif) operator(()local_variable($this)operator(->)ident(items)operator([)local_variable($artnr)operator(]) operator(==) local_variable($num)operator(\)) operator({) + predefined(unset)operator(()local_variable($this)operator(->)ident(items)operator([)local_variable($artnr)operator(])operator(\))operator(;) + reserved(return) pre_constant(true)operator(;) + operator(}) reserved(else) operator({) + reserved(return) pre_constant(false)operator(;) + operator(}) + operator(}) +operator(}) +inline_delimiter(?>) + + +inline_delimiter(operator(\))operator(;) + reserved(var) local_variable($name) operator(=) local_variable($firstname)operator(;) + reserved(var) local_variable($owner) operator(=) string operator(.) stringoperator(;) + comment(/* Arrays containing constant values will, though. */) + reserved(var) local_variable($items) operator(=) predefined(array)operator(()stringoperator(,) stringoperator(\))operator(;) +operator(}) + +comment(/* This is how it should be done. */) +reserved(class) class(Cart) operator({) + reserved(var) local_variable($todays_date)operator(;) + reserved(var) local_variable($name)operator(;) + reserved(var) local_variable($owner)operator(;) + reserved(var) local_variable($items) operator(=) predefined(array)operator(()stringoperator(,) stringoperator(\))operator(;) + + reserved(function) function(Cart)operator(()operator(\)) operator({) + local_variable($this)operator(->)ident(todays_date) operator(=) predefined(date)operator(()stringoperator(\))operator(;) + local_variable($this)operator(->)ident(name) operator(=) local_variable($GLOBALS)operator([)stringoperator(])operator(;) + comment(/* etc. . . */) + operator(}) +operator(}) +inline_delimiter(?>) + +inline_delimiter(operator(;) + predefined(echo) predefined(get_class)operator(()local_variable($this)operator(\))operator(;) + predefined(echo) stringoperator(;) + operator(}) reserved(else) operator({) + predefined(echo) stringoperator(;) + operator(}) + operator(}) +operator(}) + +reserved(class) class(B) +operator({) + reserved(function) function(bar)operator(()operator(\)) + operator({) + constant(A)operator(::)ident(foo)operator(()operator(\))operator(;) + operator(}) +operator(}) + +local_variable($a) operator(=) reserved(new) constant(A)operator(()operator(\))operator(;) +local_variable($a)operator(->)ident(foo)operator(()operator(\))operator(;) +constant(A)operator(::)ident(foo)operator(()operator(\))operator(;) +local_variable($b) operator(=) reserved(new) constant(B)operator(()operator(\))operator(;) +local_variable($b)operator(->)ident(bar)operator(()operator(\))operator(;) +constant(B)operator(::)ident(bar)operator(()operator(\))operator(;) +inline_delimiter(?>) diff --git a/test/scanners/php/class.in.php b/test/scanners/php/class.in.php new file mode 100644 index 0000000..bfc9e2d --- /dev/null +++ b/test/scanners/php/class.in.php @@ -0,0 +1,83 @@ + +items[$artnr] += $num; + } + + // Take $num articles of $artnr out of the cart + + function remove_item($artnr, $num) { + if ($this->items[$artnr] > $num) { + $this->items[$artnr] -= $num; + return true; + } elseif ($this->items[$artnr] == $num) { + unset($this->items[$artnr]); + return true; + } else { + return false; + } + } +} +?> + + +todays_date = date("Y-m-d"); + $this->name = $GLOBALS['firstname']; + /* etc. . . */ + } +} +?> + +foo(); +A::foo(); +$b = new B(); +$b->bar(); +B::bar(); +?> diff --git a/test/scanners/php/pleac.expected.raydebug b/test/scanners/php/pleac.expected.raydebug index 3054902..7ab65e4 100644 --- a/test/scanners/php/pleac.expected.raydebug +++ b/test/scanners/php/pleac.expected.raydebug @@ -23,10 +23,10 @@ local_variable($a) operator(=) stringoperator(;) -local_variable($a) operator(=) operator(<<)operator(<)constant(EOF) -constant(This) ident(is) ident(a) ident(multiline) ident(here) ident(document) -ident(terminated) ident(by) constant(EOF) ident(on) ident(a) ident(line) ident(by) ident(itself) -constant(EOF)operator(;) +local_variable($a) operator(=) stringoperator(;) comment(#-----------------------------) comment(# @@PLEAC@@_1.1) @@ -99,7 +99,7 @@ local_variable($b) operator(=) predefined(unpack)operator(()stringoperator(])operator(.)stringoperator(.)local_variable($b)operator([)stringoperator(])operator(.)stringoperator(;) comment(#-----------------------------) -reserved(function) ident(cut2fmt)operator(()operator(\)) operator({) +reserved(function) function(cut2fmt)operator(()operator(\)) operator({) local_variable($positions) operator(=) predefined(func_get_args)operator(()operator(\))operator(;) local_variable($template) operator(=) stringoperator(;) local_variable($lastpos) operator(=) integer(1)operator(;) @@ -409,7 +409,7 @@ local_variable($string) operator(=) predefined(preg_replace)operator(()stringoperator(,) stringoperator(,) local_variable($string)operator(\))operator(;) reserved(return) local_variable($string)operator(;) @@ -429,7 +429,7 @@ comment(#-----------------------------) comment(// substitution function for getpwent(\):) comment(// returns an array of user entries,) comment(// each entry contains the username and the full name) -reserved(function) ident(getpwent)operator(()operator(\)) operator({) +reserved(function) function(getpwent)operator(()operator(\)) operator({) local_variable($pwents) operator(=) predefined(array)operator(()operator(\))operator(;) local_variable($handle) operator(=) predefined(fopen)operator(()stringoperator(,) stringoperator(\))operator(;) reserved(while) operator(()operator(!)predefined(feof)operator(()local_variable($handle)operator(\))operator(\)) operator({) @@ -499,7 +499,7 @@ predefined(preg_match)operator(()stringoperator(,) local_variable($number)operator(\))operator(;) reserved(return) predefined(isset)operator(()local_variable($number)operator(\)) operator(?) local_variable($number) operator(:) integer(0)operator(;) operator(}) @@ -642,7 +642,7 @@ local_variable($random) operator(=) predefined(rand)operator(()local_variable($x comment(// ----------------------------) -reserved(function) ident(make_password)operator(()local_variable($chars)operator(,) local_variable($reqlen)operator(\)) +reserved(function) function(make_password)operator(()local_variable($chars)operator(,) local_variable($reqlen)operator(\)) operator({) local_variable($len) operator(=) predefined(strlen)operator(()local_variable($chars)operator(\))operator(;) reserved(for) operator(()local_variable($i) operator(=) integer(0)operator(;) local_variable($i) operator(<) local_variable($reqlen)operator(;) local_variable($i)operator(++)operator(\)) local_variable($password) operator(.=) predefined(substr)operator(()local_variable($chars)operator(,) predefined(rand)operator(()integer(0)operator(,) local_variable($len)operator(\))operator(,) integer(1)operator(\))operator(;) @@ -687,9 +687,9 @@ comment(// approximate the generation of a 'truly random value') local_variable($truly_random_value) operator(=) ident(mt_rand)operator(()operator(\))operator(;) comment(// @@PLEAC@@_2.10) -reserved(function) ident(random)operator(()operator(\)) operator({) reserved(return) operator(()pre_type(float)operator(\)) predefined(rand)operator(()operator(\)) operator(/) operator(()pre_type(float)operator(\)) predefined(getrandmax)operator(()operator(\))operator(;) operator(}) +reserved(function) function(random)operator(()operator(\)) operator({) reserved(return) operator(()pre_type(float)operator(\)) predefined(rand)operator(()operator(\)) operator(/) operator(()pre_type(float)operator(\)) predefined(getrandmax)operator(()operator(\))operator(;) operator(}) -reserved(function) ident(gaussian_rand)operator(()operator(\)) +reserved(function) function(gaussian_rand)operator(()operator(\)) operator({) local_variable($u1) operator(=) float(0.0)operator(;) local_variable($u2) operator(=) float(0.0)operator(;) local_variable($g1) operator(=) float(0.0)operator(;) local_variable($g2) operator(=) float(0.0)operator(;) local_variable($w) operator(=) float(0.0)operator(;) @@ -714,8 +714,8 @@ predefined(printf)operator(()stringoperator(,) ident(degree_sin)operator(()float(380.0)operator(\))operator(\))operator(;) comment(// @@PLEAC@@_2.12) -reserved(function) ident(my_tan)operator(()local_variable($theta)operator(\)) operator({) reserved(return) predefined(sin)operator(()local_variable($theta)operator(\)) operator(/) predefined(cos)operator(()local_variable($theta)operator(\))operator(;) operator(}) +reserved(function) function(my_tan)operator(()local_variable($theta)operator(\)) operator({) reserved(return) predefined(sin)operator(()local_variable($theta)operator(\)) operator(/) predefined(cos)operator(()local_variable($theta)operator(\))operator(;) operator(}) comment(// ------------) @@ -751,7 +751,7 @@ local_variable($log_10) operator(=) predefined(log10)operator(()local_variable($ comment(// ----------------------------) -reserved(function) ident(log_base)operator(()local_variable($base)operator(,) local_variable($value)operator(\)) operator({) reserved(return) predefined(log)operator(()local_variable($value)operator(\)) operator(/) predefined(log)operator(()local_variable($base)operator(\))operator(;) operator(}) +reserved(function) function(log_base)operator(()local_variable($base)operator(,) local_variable($value)operator(\)) operator({) reserved(return) predefined(log)operator(()local_variable($value)operator(\)) operator(/) predefined(log)operator(()local_variable($base)operator(\))operator(;) operator(}) comment(// ------------) @@ -844,7 +844,7 @@ comment(// @@PLEAC@@_2.17) comment(// PHP offers the 'number_format' built-in function to, among many other format tasks, ) comment(// commify numbers. Perl-compatible [as well as extended] regexes are also available) -reserved(function) ident(commify_series)operator(()local_variable($s)operator(\)) operator({) reserved(return) predefined(number_format)operator(()local_variable($s)operator(,) integer(0)operator(,) stringoperator(,) stringoperator(\))operator(;) operator(}) +reserved(function) function(commify_series)operator(()local_variable($s)operator(\)) operator({) reserved(return) predefined(number_format)operator(()local_variable($s)operator(,) integer(0)operator(,) stringoperator(,) stringoperator(\))operator(;) operator(}) comment(// ------------) @@ -854,7 +854,7 @@ predefined(printf)operator(()stringoperator(,) stringoperator(,) predefined(strrev)operator(()local_variable($s)operator(\))operator(\))operator(\))operator(;) operator(}) @@ -866,7 +866,7 @@ local_variable($hits) operator(=) integer(3456789)operator(;) predefined(echo) ident(commify)operator(()predefined(sprintf)operator(()stringoperator(,) local_variable($hits)operator(\))operator(\))operator(;) comment(// @@PLEAC@@_2.18) -reserved(function) ident(pluralise)operator(()local_variable($value)operator(,) local_variable($root)operator(,) local_variable($singular)operator(=)string operator(,) local_variable($plural)operator(=)stringoperator(\)) +reserved(function) function(pluralise)operator(()local_variable($value)operator(,) local_variable($root)operator(,) local_variable($singular)operator(=)string operator(,) local_variable($plural)operator(=)stringoperator(\)) operator({) reserved(return) local_variable($root) operator(.) operator(()operator(()local_variable($value) operator(>) integer(1)operator(\)) operator(?) local_variable($plural) operator(:) local_variable($singular)operator(\))operator(;) operator(}) @@ -885,7 +885,7 @@ predefined(printf)operator(()string operator(=>) stringoperator(,) string operator(=>) stringoperator(,) string operator(=>) stringoperator(,) string operator(=>) stringoperator(,) string operator(=>) stringoperator(,) string operator(=>) stringoperator(,) @@ -940,7 +940,7 @@ comment(// not currently shipped with PHP, no examples appear) comment(// Helper functions for performing date arithmetic ) -reserved(function) ident(dateOffset)operator(()operator(\)) +reserved(function) function(dateOffset)operator(()operator(\)) operator({) reserved(static) local_variable($tbl) operator(=) predefined(array)operator(()string operator(=>) integer(1)operator(,) string operator(=>) integer(60)operator(,) string operator(=>) integer(3600)operator(,) string operator(=>) integer(86400)operator(,) string operator(=>) integer(604800)operator(\))operator(;) local_variable($delta) operator(=) integer(0)operator(;) @@ -954,7 +954,7 @@ operator({) reserved(return) local_variable($delta)operator(;) operator(}) -reserved(function) ident(dateInterval)operator(()local_variable($intvltype)operator(,) local_variable($timevalue)operator(\)) +reserved(function) function(dateInterval)operator(()local_variable($intvltype)operator(,) local_variable($timevalue)operator(\)) operator({) reserved(static) local_variable($tbl) operator(=) predefined(array)operator(()string operator(=>) integer(1)operator(,) string operator(=>) integer(60)operator(,) string operator(=>) integer(3600)operator(,) string operator(=>) integer(86400)operator(,) string operator(=>) integer(604800)operator(\))operator(;) reserved(return) operator(()pre_type(int)operator(\)) predefined(round)operator(()local_variable($timevalue) operator(/) local_variable($tbl)operator([)predefined(strtolower)operator(()predefined(substr)operator(()local_variable($intvltype)operator(,) integer(0)operator(,) integer(3)operator(\))operator(\))operator(])operator(\))operator(;) @@ -1347,10 +1347,10 @@ local_variable($a) operator(=) predefined(escapeshellarg)operator(()stringoperator(;) comment(// ------------) @@ -1405,7 +1405,7 @@ local_variable($tags) operator(=) predefined(split)operator(()stringoperator(,) stringoperator(\))operator(;) comment(// @@PLEAC@@_4.2) -reserved(function) ident(commify_series)operator(()local_variable($list)operator(\)) +reserved(function) function(commify_series)operator(()local_variable($list)operator(\)) operator({) local_variable($n) operator(=) predefined(str_word_count)operator(()local_variable($list)operator(\))operator(;) local_variable($series) operator(=) predefined(str_word_count)operator(()local_variable($list)operator(,) integer(1)operator(\))operator(;) @@ -1427,7 +1427,7 @@ predefined(echo) string operator(.) id comment(// ----------------------------) -reserved(function) ident(commify_series)operator(()local_variable($arr)operator(\)) +reserved(function) function(commify_series)operator(()local_variable($arr)operator(\)) operator({) local_variable($n) operator(=) predefined(count)operator(()local_variable($arr)operator(\))operator(;) local_variable($sepchar) operator(=) stringoperator(;) @@ -1478,7 +1478,7 @@ local_variable($item) operator(=) predefined(array_pop)operator(()local_variable comment(// ----------------------------) -reserved(function) ident(what_about_the_array)operator(()operator(\)) +reserved(function) function(what_about_the_array)operator(()operator(\)) operator({) reserved(global) local_variable($people)operator(;) @@ -1654,7 +1654,7 @@ operator(}) comment(// ------------) -reserved(function) ident(some_func)operator(()local_variable($item)operator(\)) +reserved(function) function(some_func)operator(()local_variable($item)operator(\)) operator({) operator(;) comment(// Do something with '$item') operator(}) @@ -1803,14 +1803,14 @@ comment(// Where elements need to be removed, and those elements also returned, comment(// combine both operations in a function. This is the approach taken here in implementing both) comment(// 'shiftN' and 'popN', and it is these functions that are used in the examples) -reserved(function) ident(popN)operator(()operator(&)local_variable($arr)operator(,) local_variable($n)operator(\)) +reserved(function) function(popN)operator(()operator(&)local_variable($arr)operator(,) local_variable($n)operator(\)) operator({) local_variable($ret) operator(=) predefined(array_slice)operator(()local_variable($arr)operator(,) operator(-)operator(()local_variable($n)operator(\))operator(,) local_variable($n)operator(\))operator(;) local_variable($arr) operator(=) predefined(array_slice)operator(()local_variable($arr)operator(,) integer(0)operator(,) predefined(count)operator(()local_variable($arr)operator(\)) operator(-) local_variable($n)operator(\))operator(;) reserved(return) local_variable($ret)operator(;) operator(}) -reserved(function) ident(shiftN)operator(()operator(&)local_variable($arr)operator(,) local_variable($n)operator(\)) +reserved(function) function(shiftN)operator(()operator(&)local_variable($arr)operator(,) local_variable($n)operator(\)) operator({) local_variable($ret) operator(=) predefined(array_slice)operator(()local_variable($arr)operator(,) integer(0)operator(,) local_variable($n)operator(\))operator(;) local_variable($arr) operator(=) predefined(array_slice)operator(()local_variable($arr)operator(,) local_variable($n)operator(\))operator(;) @@ -1879,7 +1879,7 @@ operator(}) comment(// ------------) -reserved(function) ident(predicate)operator(()local_variable($element)operator(\)) +reserved(function) function(predicate)operator(()local_variable($element)operator(\)) operator({) reserved(if) operator(()ident(criterion)operator(\)) reserved(return) pre_constant(TRUE)operator(;) reserved(return) pre_constant(FALSE)operator(;) @@ -1898,11 +1898,11 @@ operator(}) comment(// ----------------------------) -reserved(class) constant(Employee) +reserved(class) class(Employee) operator({) reserved(public) local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(;) - reserved(public) reserved(function) ident(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(,) local_variable($category)operator(\)) + reserved(public) reserved(function) function(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(,) local_variable($category)operator(\)) operator({) local_variable($this)operator(->)ident(name) operator(=) local_variable($name)operator(;) local_variable($this)operator(->)ident(age) operator(=) local_variable($age)operator(;) @@ -1921,13 +1921,13 @@ local_variable($employees) operator(=) predefined(array)operator(() comment(// ------------) -reserved(function) ident(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) +reserved(function) function(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) operator({) reserved(foreach)operator(()local_variable($arr) reserved(as) local_variable($key)operator(\)) local_variable($lambda)operator(()local_variable($updarr)operator(,) local_variable($key)operator(\))operator(;) reserved(return) local_variable($updarr)operator(;) operator(}) -reserved(function) ident(highest_salaried_engineer)operator(()operator(&)local_variable($arr)operator(,) local_variable($employee)operator(\)) +reserved(function) function(highest_salaried_engineer)operator(()operator(&)local_variable($arr)operator(,) local_variable($employee)operator(\)) operator({) reserved(static) local_variable($highest_salary) operator(=) integer(0)operator(;) @@ -1954,7 +1954,7 @@ comment(// @@PLEAC@@_4.13) comment(// PHP implements 'grep' functionality [as embodied in the current section] in the 'array_filter') comment(// function) -reserved(function) ident(predicate)operator(()local_variable($element)operator(\)) +reserved(function) function(predicate)operator(()local_variable($element)operator(\)) operator({) reserved(if) operator(()ident(criterion)operator(\)) reserved(return) pre_constant(TRUE)operator(;) reserved(return) pre_constant(FALSE)operator(;) @@ -1968,7 +1968,7 @@ local_variable($bigs) operator(=) predefined(array_filter)operator(()local_varia comment(// ------------) -reserved(function) ident(is_pig)operator(()local_variable($user)operator(\)) +reserved(function) function(is_pig)operator(()local_variable($user)operator(\)) operator({) local_variable($user_details) operator(=) predefined(preg_split)operator(()stringoperator(,) local_variable($user)operator(\))operator(;) comment(// Assuming field 5 is the resource being compared) @@ -1984,11 +1984,11 @@ local_variable($matching) operator(=) predefined(array_filter)operator(()predefi comment(// ------------) -reserved(class) constant(Employee) +reserved(class) class(Employee) operator({) reserved(public) local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(;) - reserved(public) reserved(function) ident(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(,) local_variable($category)operator(\)) + reserved(public) reserved(function) function(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(,) local_variable($category)operator(\)) operator({) local_variable($this)operator(->)ident(name) operator(=) local_variable($name)operator(;) local_variable($this)operator(->)ident(age) operator(=) local_variable($age)operator(;) @@ -2037,8 +2037,8 @@ predefined(natsort)operator(()local_variable($unsorted)operator(\))operator(;) comment(// ------------) -reserved(function) ident(ascend)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) operator({) reserved(return) local_variable($left) operator(>) local_variable($right)operator(;) operator(}) -reserved(function) ident(descend)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) operator({) reserved(return) local_variable($left) operator(<) local_variable($right)operator(;) operator(}) +reserved(function) function(ascend)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) operator({) reserved(return) local_variable($left) operator(>) local_variable($right)operator(;) operator(}) +reserved(function) function(descend)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) operator({) reserved(return) local_variable($left) operator(<) local_variable($right)operator(;) operator(}) comment(// ------------) @@ -2050,7 +2050,7 @@ predefined(uasort)operator(()local_variable($unsorted)operator(,) stringoperator(,) predefined(trim)operator(()local_variable($pentry)operator(\))operator(\))operator(;) reserved(return) local_variable($p)operator([)integer(0)operator(])operator(;) @@ -2083,7 +2083,7 @@ comment(// A significant difference from the Perl examples is that these functio comment(// inplace sorters, so it is the original array that is modified. Where this must) comment(// be prevented a copy of the array can be made and sorted) -reserved(function) ident(comparator)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) +reserved(function) function(comparator)operator(()local_variable($left)operator(,) local_variable($right)operator(\)) operator({) operator(;) comment(// Compare '$left' with '$right' returning result) operator(}) @@ -2099,7 +2099,7 @@ comment(// The Perl example looks like it is creating a hash using computed valu comment(// array values as the value, sorting on the computed key, then extracting the sorted) comment(// values and placing them back into an array) -reserved(function) ident(compute)operator(()local_variable($value)operator(\)) +reserved(function) function(compute)operator(()local_variable($value)operator(\)) operator({) operator(;) comment(// Return computed value utilising '$value') operator(}) @@ -2127,20 +2127,20 @@ comment(// ----------------------------) comment(// As above, except uses 'array_update' and 'accum' to help create hash) -reserved(function) ident(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) +reserved(function) function(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) operator({) reserved(foreach)operator(()local_variable($arr) reserved(as) local_variable($key)operator(\)) local_variable($lambda)operator(()local_variable($updarr)operator(,) local_variable($key)operator(\))operator(;) reserved(return) local_variable($updarr)operator(;) operator(}) -reserved(function) ident(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) +reserved(function) function(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) operator({) local_variable($arr)operator([)ident(compute)operator(()local_variable($value)operator(\))operator(]) operator(=) local_variable($value)operator(;) operator(}) comment(// ------------) -reserved(function) ident(compute)operator(()local_variable($value)operator(\)) +reserved(function) function(compute)operator(()local_variable($value)operator(\)) operator({) operator(;) comment(// Return computed value utilising '$value') operator(}) @@ -2162,11 +2162,11 @@ local_variable($ordered) operator(=) predefined(array_values)operator(()local_va comment(// ----------------------------) -reserved(class) constant(Employee) +reserved(class) class(Employee) operator({) reserved(public) local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(;) - reserved(public) reserved(function) ident(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(\)) + reserved(public) reserved(function) function(__construct)operator(()local_variable($name)operator(,) local_variable($age)operator(,) local_variable($ssn)operator(,) local_variable($salary)operator(\)) operator({) local_variable($this)operator(->)ident(name) operator(=) local_variable($name)operator(;) local_variable($this)operator(->)ident(age) operator(=) local_variable($age)operator(;) @@ -2219,9 +2219,9 @@ comment(// manipulation, these functions won't be used. Instead a custom functio comment(// 'getpwent' function will be implemented so the code presented here can more faithfully match) comment(// the Perl code) -reserved(function) ident(get_pw_entries)operator(()operator(\)) +reserved(function) function(get_pw_entries)operator(()operator(\)) operator({) - reserved(function) ident(normal_users_only)operator(()local_variable($e)operator(\)) + reserved(function) function(normal_users_only)operator(()local_variable($e)operator(\)) operator({) local_variable($entry) operator(=) predefined(split)operator(()stringoperator(,) local_variable($e)operator(\))operator(;) reserved(return) local_variable($entry)operator([)integer(2)operator(]) operator(>) integer(100) operator(&&) local_variable($entry)operator([)integer(2)operator(]) operator(<) integer(32768)operator(;) operator(}) @@ -2255,13 +2255,13 @@ predefined(usort)operator(()local_variable($sorted)operator(,) ident(create_func comment(// ----------------------------) -reserved(function) ident(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) +reserved(function) function(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) operator({) reserved(foreach)operator(()local_variable($arr) reserved(as) local_variable($key)operator(\)) local_variable($lambda)operator(()local_variable($updarr)operator(,) local_variable($key)operator(\))operator(;) reserved(return) local_variable($updarr)operator(;) operator(}) -reserved(function) ident(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) +reserved(function) function(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) operator({) local_variable($arr)operator([)predefined(strlen)operator(()local_variable($value)operator(\))operator(]) operator(=) local_variable($value)operator(;) operator(}) @@ -2276,13 +2276,13 @@ local_variable($sorted) operator(=) predefined(array_values)operator(()local_var comment(// ----------------------------) -reserved(function) ident(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) +reserved(function) function(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) operator({) reserved(foreach)operator(()local_variable($arr) reserved(as) local_variable($key)operator(\)) local_variable($lambda)operator(()local_variable($updarr)operator(,) local_variable($key)operator(\))operator(;) reserved(return) local_variable($updarr)operator(;) operator(}) -reserved(function) ident(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) +reserved(function) function(accum)operator(()operator(&)local_variable($arr)operator(,) local_variable($value)operator(\)) operator({) reserved(if) operator(()predefined(preg_match)operator(()stringoperator(,) local_variable($value)operator(,) local_variable($matches)operator(\))operator(\)) local_variable($arr)operator([)local_variable($matches)operator([)integer(1)operator(])operator(]) operator(=) local_variable($value)operator(;) @@ -2302,7 +2302,7 @@ predefined(array_push)operator(()local_variable($a1)operator(,) predefined(array comment(// ----------------------------) -reserved(function) ident(grab_and_rotate)operator(()operator(&)local_variable($arr)operator(\)) +reserved(function) function(grab_and_rotate)operator(()operator(&)local_variable($arr)operator(\)) operator({) local_variable($item) operator(=) local_variable($arr)operator([)integer(0)operator(])operator(;) predefined(array_push)operator(()local_variable($arr)operator(,) predefined(array_shift)operator(()local_variable($arr)operator(\))operator(\))operator(;) @@ -2332,7 +2332,7 @@ predefined(echo) predefined(join)operator(()string) local_variable($right)operator(;) @@ -3022,7 +3022,7 @@ comment(// ----------------------------) comment(// For the simple task of determining whether a file contains, text', a simple) comment(// function that searches for a newline could be implemented. Not exactly) comment(// foolproof, but very simple, low overhead, no installation headaches ...) -reserved(function) ident(containsText)operator(()local_variable($file)operator(\)) +reserved(function) function(containsText)operator(()local_variable($file)operator(\)) operator({) local_variable($status) operator(=) pre_constant(FALSE)operator(;) @@ -3043,7 +3043,7 @@ comment(// PHP offers the [currently experimental] Fileinfo group of functions t comment(// determine file types based on their contents / 'magic numbers'. This) comment(// is functionality similar to the *NIX, 'file' utility. Note that it must) comment(// first be installed using the PEAR utility [see PHP documentation] ) -reserved(function) ident(isTextFile)operator(()local_variable($file)operator(\)) +reserved(function) function(isTextFile)operator(()local_variable($file)operator(\)) operator({) comment(// Note: untested code, but I believe this is how it is supposed to work) local_variable($finfo) operator(=) ident(finfo_open)operator(()constant(FILEINFO_NONE)operator(\))operator(;) @@ -3053,7 +3053,7 @@ operator({) operator(}) comment(// Alternatively, use the *NIX utility, 'file', directly) -reserved(function) ident(isTextFile)operator(()local_variable($file)operator(\)) +reserved(function) function(isTextFile)operator(()local_variable($file)operator(\)) operator({) reserved(return) predefined(exec)operator(()predefined(trim)operator(()string operator(.) predefined(escapeshellarg)operator(()local_variable($file)operator(\))operator(\))operator(\)) operator(==) stringoperator(;) operator(}) @@ -3179,7 +3179,7 @@ operator(}) comment(// ------------) -reserved(function) ident(rmAll)operator(()local_variable($files)operator(\)) +reserved(function) function(rmAll)operator(()local_variable($files)operator(\)) operator({) local_variable($count) operator(=) integer(0)operator(;) @@ -3263,7 +3263,7 @@ comment(// * command being 'exec'ed) comment(// as the rest of the code is platform independant) comment(// @@PLEAC@@_9.4) -reserved(function) ident(makeDevInodePair)operator(()local_variable($filename)operator(\)) +reserved(function) function(makeDevInodePair)operator(()local_variable($filename)operator(\)) operator({) reserved(if) operator(()operator(!)operator(()local_variable($fs) operator(=) operator(@)predefined(stat)operator(()local_variable($filename)operator(\))operator(\))operator(\)) reserved(return) pre_constant(FALSE)operator(;) reserved(return) predefined(strval)operator(()local_variable($fs)operator([)stringoperator(]) operator(.) local_variable($fs)operator([)stringoperator(])operator(\))operator(;) @@ -3271,7 +3271,7 @@ operator(}) comment(// ------------) -reserved(function) ident(do_my_thing)operator(()local_variable($filename)operator(\)) +reserved(function) function(do_my_thing)operator(()local_variable($filename)operator(\)) operator({) comment(// Using a global variable to mimic Perl example, but could easily have passed) comment(// '$seen' as an argument) @@ -3316,13 +3316,13 @@ comment(// easily-implemented 'higher order' techniques) comment(// Helper function loosely modelled on, 'array_reduce', but using an array as) comment(// 'accumulator', which is returned on completion) -reserved(function) ident(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) +reserved(function) function(array_update)operator(()local_variable($arr)operator(,) local_variable($lambda)operator(,) local_variable($updarr)operator(\)) operator({) reserved(foreach)operator(()local_variable($arr) reserved(as) local_variable($key)operator(\)) local_variable($lambda)operator(()local_variable($updarr)operator(,) local_variable($key)operator(\))operator(;) reserved(return) local_variable($updarr)operator(;) operator(}) -reserved(function) ident(do_my_thing)operator(()operator(&)local_variable($seen)operator(,) local_variable($filename)operator(\)) +reserved(function) function(do_my_thing)operator(()operator(&)local_variable($seen)operator(,) local_variable($filename)operator(\)) operator({) reserved(if) operator(()operator(!)predefined(array_key_exists)operator(()operator(()local_variable($devino) operator(=) ident(makeDevInodePair)operator(()local_variable($filename)operator(\))operator(\))operator(,) local_variable($seen)operator(\))operator(\)) operator({) @@ -3446,7 +3446,7 @@ operator(}) comment(// ----------------------------) -reserved(function) ident(plain_files)operator(()local_variable($dirname)operator(\)) +reserved(function) function(plain_files)operator(()local_variable($dirname)operator(\)) operator({) operator(()local_variable($dirlist) operator(=) predefined(glob)operator(()local_variable($dirname) operator(.) stringoperator(\))operator(\)) operator(||) predefined(die)operator(()stringchar(\\n)delimiter(")>operator(\))operator(;) @@ -3497,15 +3497,15 @@ comment(// Recursive directory traversal function and helper: traverses a direct comment(// applying a function [and a variable number of accompanying arguments] to each) comment(// file) -reserved(class) constant(Accumulator) +reserved(class) class(Accumulator) operator({) reserved(public) local_variable($value)operator(;) - reserved(public) reserved(function) ident(__construct)operator(()local_variable($start_value)operator(\)) operator({) local_variable($this)operator(->)ident(value) operator(=) local_variable($start_value)operator(;) operator(}) + reserved(public) reserved(function) function(__construct)operator(()local_variable($start_value)operator(\)) operator({) local_variable($this)operator(->)ident(value) operator(=) local_variable($start_value)operator(;) operator(}) operator(}) comment(// ------------) -reserved(function) ident(process_directory_)operator(()local_variable($op)operator(,) local_variable($func_args)operator(\)) +reserved(function) function(process_directory_)operator(()local_variable($op)operator(,) local_variable($func_args)operator(\)) operator({) reserved(if) operator(()predefined(is_dir)operator(()local_variable($func_args)operator([)integer(0)operator(])operator(\))operator(\)) operator({) @@ -3523,7 +3523,7 @@ operator({) operator(}) operator(}) -reserved(function) ident(process_directory)operator(()local_variable($op)operator(,) local_variable($dir)operator(\)) +reserved(function) function(process_directory)operator(()local_variable($op)operator(,) local_variable($dir)operator(\)) operator({) reserved(if) operator(()operator(!)predefined(is_dir)operator(()local_variable($dir)operator(\))operator(\)) reserved(return) pre_constant(FALSE)operator(;) local_variable($func_args) operator(=) predefined(array_slice)operator(()predefined(func_get_args)operator(()operator(\))operator(,) integer(1)operator(\))operator(;) @@ -3549,7 +3549,7 @@ comment(// ------------) local_variable($dirlist) operator(=) predefined(array)operator(()stringoperator(,) stringoperator(,) stringoperator(\))operator(;) -reserved(function) ident(pf)operator(()local_variable($path)operator(\)) +reserved(function) function(pf)operator(()local_variable($path)operator(\)) operator({) comment(// ... do something to the file or directory ...) predefined(printf)operator(()stringoperator(,) local_variable($path)operator(\))operator(;) @@ -3580,7 +3580,7 @@ operator(}) comment(// ----------------------------) -reserved(function) ident(accum_filesize)operator(()local_variable($file)operator(,) local_variable($accum)operator(\)) +reserved(function) function(accum_filesize)operator(()local_variable($file)operator(,) local_variable($accum)operator(\)) operator({) predefined(is_file)operator(()local_variable($file)operator(\)) operator(&&) operator(()local_variable($accum)operator(->)ident(value) operator(+=) predefined(filesize)operator(()local_variable($file)operator(\))operator(\))operator(;) operator(}) @@ -3602,7 +3602,7 @@ predefined(printf)operator(()stringoperator(;) @@ -3694,7 +3694,7 @@ operator({) operator(}) comment(// Launcher - performs validation then starts recursive routine) -reserved(function) ident(rmtree)operator(()local_variable($dir)operator(\)) +reserved(function) function(rmtree)operator(()local_variable($dir)operator(\)) operator({) reserved(if) operator(()predefined(is_dir)operator(()local_variable($dir)operator(\))operator(\)) operator({) @@ -3801,7 +3801,7 @@ predefined(printf)operator(()stringoperator(\)) +reserved(function) function(file_extension)operator(()local_variable($filename)operator(,) local_variable($separator) operator(=) stringoperator(\)) operator({) reserved(return) predefined(end)operator(()predefined(split)operator(()operator(()string operator(.) local_variable($separator)operator(\))operator(,) local_variable($filename)operator(\))operator(\))operator(;) operator(}) @@ -3827,13 +3827,13 @@ comment(// ------------) comment(// Must use, 'global', keyword to inform functions that $greeted already exists as) comment(// a global variable. If this is not done, a local variable of that name is implicitly) comment(// defined) -reserved(function) ident(howManyGreetings)operator(()operator(\)) +reserved(function) function(howManyGreetings)operator(()operator(\)) operator({) reserved(global) local_variable($greeted)operator(;) reserved(return) local_variable($greeted)operator(;) operator(}) -reserved(function) ident(hello)operator(()operator(\)) +reserved(function) function(hello)operator(()operator(\)) operator({) reserved(global) local_variable($greeted)operator(;) local_variable($greeted)operator(++)operator(;) @@ -3848,7 +3848,7 @@ predefined(echo) stringoperator(,) stringoperator(\))operator(,) local_variable($arr)operator(\))operator(;) operator(}) comment(// Pass-by-reference) -reserved(function) ident(trunc_em)operator(()operator(&)local_variable($n)operator(\)) +reserved(function) function(trunc_em)operator(()operator(&)local_variable($n)operator(\)) operator({) reserved(foreach) operator(()local_variable($n) reserved(as) operator(&)local_variable($value)operator(\)) local_variable($value) operator(=) operator(()pre_type(int)operator(\)) local_variable($value)operator(;) operator(}) @@ -3932,7 +3932,7 @@ comment(// declared 'global', and those names are then taken to refer to entries comment(// in the $GLOBALS array rather than seeing local variables of that name) comment(// accessed or defined) -reserved(function) ident(some_func)operator(()operator(\)) +reserved(function) function(some_func)operator(()operator(\)) operator({) comment(// Variables declared within a function are local to that function) local_variable($variable) operator(=) stringoperator(;) @@ -3949,7 +3949,7 @@ local_variable($condition) operator(=) integer(0)operator(;) comment(// ------------) -reserved(function) ident(run_check)operator(()operator(\)) +reserved(function) function(run_check)operator(()operator(\)) operator({) comment(// The globally-declared variable, '$condition', is not accessable within) comment(// the function unless it declared as 'global. Had this not been done then) @@ -3961,7 +3961,7 @@ operator({) comment(// ...) operator(}) -reserved(function) ident(check_x)operator(()local_variable($x)operator(\)) +reserved(function) function(check_x)operator(()local_variable($x)operator(\)) operator({) local_variable($y) operator(=) stringoperator(;) @@ -4007,7 +4007,7 @@ operator({) comment(// * 'next_counter' has no implict access to '$counter'; must be granted) comment(// via 'global' keyword) - reserved(function) ident(next_counter)operator(()operator(\)) operator({) reserved(global) local_variable($counter)operator(;) local_variable($counter)operator(++)operator(;) operator(}) + reserved(function) function(next_counter)operator(()operator(\)) operator({) reserved(global) local_variable($counter)operator(;) local_variable($counter)operator(++)operator(;) operator(}) operator(}) comment(// ----------------------------) @@ -4016,16 +4016,16 @@ comment(// PHP doesn't, AFAIK, offer an equivalent to Perl's BEGIN block. Simila comment(// behaviour may be obtained by defining a class, and including such code) comment(// in its constructor) -reserved(class) constant(BEGIN) +reserved(class) class(BEGIN) operator({) reserved(private) local_variable($myvariable)operator(;) - reserved(function) ident(__construct)operator(()operator(\)) + reserved(function) function(__construct)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(myvariable) operator(=) integer(5)operator(;) operator(}) - reserved(function) ident(othersub)operator(()operator(\)) + reserved(function) function(othersub)operator(()operator(\)) operator({) predefined(echo) local_variable($this)operator(->)ident(myvariable) operator(.) stringoperator(;) operator(}) @@ -4043,17 +4043,17 @@ comment(// PHP, like C, supports 'static' local variables, that is, those that u comment(// first access are initialised, and thence retain their value between function) comment(// calls. However, the 'counter' example is better implemented as a class) -reserved(class) constant(Counter) +reserved(class) class(Counter) operator({) reserved(private) local_variable($counter)operator(;) - reserved(function) ident(__construct)operator(()local_variable($counter_init)operator(\)) + reserved(function) function(__construct)operator(()local_variable($counter_init)operator(\)) operator({) local_variable($this)operator(->)ident(counter) operator(=) local_variable($counter_init)operator(;) operator(}) - reserved(function) ident(next_counter)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(counter)operator(++)operator(;) reserved(return) local_variable($this)operator(->)ident(counter)operator(;) operator(}) - reserved(function) ident(prev_counter)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(counter)operator(;) reserved(return) local_variable($this)operator(->)ident(counter)operator(;) operator(}) + reserved(function) function(next_counter)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(counter)operator(++)operator(;) reserved(return) local_variable($this)operator(->)ident(counter)operator(;) operator(}) + reserved(function) function(prev_counter)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(counter)operator(;) reserved(return) local_variable($this)operator(->)ident(counter)operator(;) operator(}) operator(}) comment(// ------------) @@ -4076,7 +4076,7 @@ comment(// So, to solve this problem would seem to require adopting a convention comment(// a string representing the function name is passed as an argument, or a local) comment(// variable [perhaps called, '$name'] is so set [contrived, and of limited use]) -reserved(function) ident(whoami)operator(()operator(\)) +reserved(function) function(whoami)operator(()operator(\)) operator({) local_variable($name) operator(=) stringoperator(;) predefined(echo) stringchar(\\n)delimiter(")>operator(;) @@ -4104,14 +4104,14 @@ comment(// is not altered.) comment(// A copy of the item referred to by, '$arr', is made, and altered; original) comment(// remains intact) -reserved(function) ident(array_by_value)operator(()local_variable($arr)operator(\)) +reserved(function) function(array_by_value)operator(()local_variable($arr)operator(\)) operator({) local_variable($arr)operator([)integer(0)operator(]) operator(=) integer(7)operator(;) predefined(echo) local_variable($arr)operator([)integer(0)operator(]) operator(.) stringoperator(;) operator(}) comment(// No copy is made; original item referred to by, '$arr', is altered) -reserved(function) ident(array_by_ref)operator(()operator(&)local_variable($arr)operator(\)) +reserved(function) function(array_by_ref)operator(()operator(&)local_variable($arr)operator(\)) operator({) local_variable($arr)operator([)integer(0)operator(]) operator(=) integer(7)operator(;) predefined(echo) local_variable($arr)operator([)integer(0)operator(]) operator(.) stringoperator(;) @@ -4135,7 +4135,7 @@ comment(// ----------------------------) comment(// Since, 'add_vecpair', does not attempt to alter either, '$x' or '$y', it makes) comment(// no difference whether they are 'passed by value', or 'passed by reference') -reserved(function) ident(add_vecpair)operator(()local_variable($x)operator(,) local_variable($y)operator(\)) +reserved(function) function(add_vecpair)operator(()local_variable($x)operator(,) local_variable($y)operator(\)) operator({) local_variable($r) operator(=) predefined(array)operator(()operator(\))operator(;) local_variable($length) operator(=) predefined(count)operator(()local_variable($x)operator(\))operator(;) @@ -4163,7 +4163,7 @@ comment(// when obtaining it's return value. As for Perl-style 'return context', comment(// don't believe it is supported by PHP) comment(// Can return any type) -reserved(function) ident(mysub)operator(()operator(\)) +reserved(function) function(mysub)operator(()operator(\)) operator({) comment(// ...) reserved(return) integer(5)operator(;) @@ -4201,13 +4201,13 @@ comment(// PHP doesn't directly support named / keyword parameters, but these ca comment(// easily mimiced using a class of key / value pairs, and passing a variable) comment(// number of arguments) -reserved(class) constant(KeyedValue) +reserved(class) class(KeyedValue) operator({) reserved(public) local_variable($key)operator(,) local_variable($value)operator(;) - reserved(public) reserved(function) ident(__construct)operator(()local_variable($key)operator(,) local_variable($value)operator(\)) operator({) local_variable($this)operator(->)predefined(key) operator(=) local_variable($key)operator(;) local_variable($this)operator(->)ident(value) operator(=) local_variable($value)operator(;) operator(}) + reserved(public) reserved(function) function(__construct)operator(()local_variable($key)operator(,) local_variable($value)operator(\)) operator({) local_variable($this)operator(->)predefined(key) operator(=) local_variable($key)operator(;) local_variable($this)operator(->)ident(value) operator(=) local_variable($value)operator(;) operator(}) operator(}) -reserved(function) ident(the_func)operator(()operator(\)) +reserved(function) function(the_func)operator(()operator(\)) operator({) reserved(foreach) operator(()predefined(func_get_args)operator(()operator(\)) reserved(as) local_variable($arg)operator(\)) operator({) @@ -4228,7 +4228,7 @@ comment(// With the aid of the 'extract' built-in function, the key part of this comment(// may be intsntiated to a variable name, thus more closely approximating the) comment(// behaviour of true named parameters) -reserved(function) ident(the_func)operator(()local_variable($var_array)operator(\)) +reserved(function) function(the_func)operator(()local_variable($var_array)operator(\)) operator({) predefined(extract)operator(()local_variable($var_array)operator(\))operator(;) @@ -4243,13 +4243,13 @@ ident(the_func)operator(()predefined(array)operator(()string)predefined(time) operator(=) local_variable($time)operator(;) local_variable($this)operator(->)ident(dim) operator(=) local_variable($dim)operator(;) operator(}) + reserved(public) reserved(function) function(__construct)operator(()local_variable($time)operator(,) local_variable($dim)operator(\)) operator({) local_variable($this)operator(->)predefined(time) operator(=) local_variable($time)operator(;) local_variable($this)operator(->)ident(dim) operator(=) local_variable($dim)operator(;) operator(}) operator(}) -reserved(function) ident(the_func)operator(()local_variable($var_array)operator(\)) +reserved(function) function(the_func)operator(()local_variable($var_array)operator(\)) operator({) predefined(extract)operator(()local_variable($var_array)operator(\))operator(;) @@ -4275,7 +4275,7 @@ comment(// construct] may be used to perform multiple assignments from a numeric comment(// indexed array of values, and offers the added bonus of being able to skip) comment(// assignment of one, or more, of those values) -reserved(function) ident(func)operator(()operator(\)) operator({) reserved(return) predefined(array)operator(()integer(3)operator(,) integer(6)operator(,) integer(9)operator(\))operator(;) operator(}) +reserved(function) function(func)operator(()operator(\)) operator({) reserved(return) predefined(array)operator(()integer(3)operator(,) integer(6)operator(,) integer(9)operator(\))operator(;) operator(}) comment(// ------------) @@ -4300,7 +4300,7 @@ comment(// @@PLEAC@@_10.9) comment(// Multiple return values are possible via packing a set of values within a) comment(// numerically-indexed array and using 'list' to extract them) -reserved(function) ident(some_func)operator(()operator(\)) operator({) reserved(return) predefined(array)operator(()predefined(array)operator(()integer(1)operator(,) integer(2)operator(,) integer(3)operator(\))operator(,) predefined(array)operator(()string operator(=>) integer(1)operator(,) string operator(=>) integer(2)operator(\))operator(\))operator(;) operator(}) +reserved(function) function(some_func)operator(()operator(\)) operator({) reserved(return) predefined(array)operator(()predefined(array)operator(()integer(1)operator(,) integer(2)operator(,) integer(3)operator(\))operator(,) predefined(array)operator(()string operator(=>) integer(1)operator(,) string operator(=>) integer(2)operator(\))operator(\))operator(;) operator(}) comment(// ------------) @@ -4308,7 +4308,7 @@ predefined(list)operator(()local_variable($arr)operator(,) local_variable($hash) comment(// ----------------------------) -reserved(function) ident(some_func)operator(()operator(&)local_variable($arr)operator(,) operator(&)local_variable($hash)operator(\)) operator({) reserved(return) predefined(array)operator(()local_variable($arr)operator(,) local_variable($hash)operator(\))operator(;) operator(}) +reserved(function) function(some_func)operator(()operator(&)local_variable($arr)operator(,) operator(&)local_variable($hash)operator(\)) operator({) reserved(return) predefined(array)operator(()local_variable($arr)operator(,) local_variable($hash)operator(\))operator(;) operator(}) comment(// ------------) @@ -4322,7 +4322,7 @@ comment(// value on success, and FALSE on exit. Whilst it is possible to return comment(// one of the recognised 'empty' values [e.g. '' or 0 or an empty array etc],) comment(// FALSE actually seems to be the preferred means of indicating failure) -reserved(function) ident(a_func)operator(()operator(\)) operator({) reserved(return) pre_constant(FALSE)operator(;) operator(}) +reserved(function) function(a_func)operator(()operator(\)) operator({) reserved(return) pre_constant(FALSE)operator(;) operator(}) ident(a_func)operator(()operator(\)) operator(||) predefined(die)operator(()stringoperator(\))operator(;) @@ -4344,30 +4344,30 @@ comment(// positional order, and optionally, whether a parameter is passed by) comment(// reference; no type information is present]. In short, prototyping in) comment(// PHP is optional, and limited) -reserved(function) ident(func_with_one_arg)operator(()local_variable($arg1)operator(\)) +reserved(function) function(func_with_one_arg)operator(()local_variable($arg1)operator(\)) operator({) operator(;) comment(// ...) operator(}) -reserved(function) ident(func_with_two_arg)operator(()local_variable($arg1)operator(,) local_variable($arg2)operator(\)) +reserved(function) function(func_with_two_arg)operator(()local_variable($arg1)operator(,) local_variable($arg2)operator(\)) operator({) operator(;) comment(// ...) operator(}) -reserved(function) ident(func_with_three_arg)operator(()local_variable($arg1)operator(,) local_variable($arg2)operator(,) local_variable($arg3)operator(\)) +reserved(function) function(func_with_three_arg)operator(()local_variable($arg1)operator(,) local_variable($arg2)operator(,) local_variable($arg3)operator(\)) operator({) operator(;) comment(// ...) operator(}) comment(// The following may be interpreted as meaning a function accepting no) comment(// arguments:) -reserved(function) ident(func_with_no_arg)operator(()operator(\)) +reserved(function) function(func_with_no_arg)operator(()operator(\)) operator({) operator(;) comment(// ...) operator(}) comment(// whilst the following may mean a function taking zero or more arguments) -reserved(function) ident(func_with_no_arg_information)operator(()operator(\)) +reserved(function) function(func_with_no_arg_information)operator(()operator(\)) operator({) operator(;) comment(// ...) operator(}) @@ -4387,7 +4387,7 @@ comment(// of their respective languages. A simple, canonical example follows:) comment(// Usual to derive new exception classes from the built-in, 'Exception',) comment(// class) -reserved(class) constant(MyException) reserved(extends) pre_constant(Exception) +reserved(class) class(MyException) reserved(extends) pre_constant(Exception) operator({) comment(// ...) operator(}) @@ -4408,7 +4408,7 @@ operator(}) comment(// ----------------------------) -reserved(class) constant(FullMoonException) reserved(extends) pre_constant(Exception) +reserved(class) class(FullMoonException) reserved(extends) pre_constant(Exception) operator({) comment(// ...) operator(}) @@ -4456,7 +4456,7 @@ comment(// then just assign the function name to a variable, and execute using t comment(// variable name) comment(// Original function) -reserved(function) ident(expand)operator(()operator(\)) operator({) predefined(echo) stringoperator(;) operator(}) +reserved(function) function(expand)operator(()operator(\)) operator({) predefined(echo) stringoperator(;) operator(}) comment(// Prove that function exists) predefined(echo) operator(()predefined(function_exists)operator(()stringoperator(\)) operator(?) string operator(:) stringoperator(\)) operator(.) stringoperator(;) @@ -4474,7 +4474,7 @@ predefined(unset)operator(()local_variable($grow)operator(\))operator(;) comment(// ----------------------------) -reserved(function) ident(fred)operator(()operator(\)) operator({) predefined(echo) stringoperator(;) operator(}) +reserved(function) function(fred)operator(()operator(\)) operator({) predefined(echo) stringoperator(;) operator(}) local_variable($barney) operator(=) stringoperator(;) @@ -4498,7 +4498,7 @@ local_variable($fred)operator(()operator(\))operator(;) comment(// ----------------------------) -reserved(function) ident(red)operator(()local_variable($text)operator(\)) operator({) reserved(return) string)local_variable($text)content()delimiter(")>operator(;) operator(}) +reserved(function) function(red)operator(()local_variable($text)operator(\)) operator({) reserved(return) string)local_variable($text)content()delimiter(")>operator(;) operator(}) predefined(echo) ident(red)operator(()stringoperator(\)) operator(.) stringoperator(;) @@ -4532,7 +4532,7 @@ comment(// PHP sports an AUTOLOAD facility that is quite easy to use, but, AFAIC comment(// towards the detection of unavailable classes rather than for individual functions.) comment(// Here is a rudimentary example:) -reserved(function) ident(__autoload)operator(()local_variable($classname)operator(\)) +reserved(function) function(__autoload)operator(()local_variable($classname)operator(\)) operator({) reserved(if) operator(()operator(!)predefined(file_exists)operator(()local_variable($classname)operator(\))operator(\)) operator({) @@ -4604,10 +4604,10 @@ comment(// * Do not form a closure: the inner function is merely 'parked' within comment(// outer function, and has no implicit access to the outer function's variables) comment(// or other inner functions) -reserved(function) ident(outer)operator(()local_variable($arg)operator(\)) +reserved(function) function(outer)operator(()local_variable($arg)operator(\)) operator({) local_variable($x) operator(=) local_variable($arg) operator(+) integer(35)operator(;) - reserved(function) ident(inner)operator(()operator(\)) operator({) reserved(return) local_variable($x) operator(*) integer(19)operator(;) operator(}) + reserved(function) function(inner)operator(()operator(\)) operator({) reserved(return) local_variable($x) operator(*) integer(19)operator(;) operator(}) comment(// *** wrong *** 'inner' returns 0 * 19, not ($arg + 35\) * 19) reserved(return) local_variable($x) operator(+) ident(inner)operator(()operator(\))operator(;) @@ -4615,13 +4615,13 @@ operator(}) comment(// ----------------------------) -reserved(function) ident(outer)operator(()local_variable($arg)operator(\)) +reserved(function) function(outer)operator(()local_variable($arg)operator(\)) operator({) local_variable($x) operator(=) local_variable($arg) operator(+) integer(35)operator(;) comment(// No implicit access to outer function scope; any required data must be) comment(// explicity passed) - reserved(function) ident(inner)operator(()local_variable($x)operator(\)) operator({) reserved(return) local_variable($x) operator(*) integer(19)operator(;) operator(}) + reserved(function) function(inner)operator(()local_variable($x)operator(\)) operator({) reserved(return) local_variable($x) operator(*) integer(19)operator(;) operator(}) reserved(return) local_variable($x) operator(+) ident(inner)operator(()local_variable($x)operator(\))operator(;) operator(}) @@ -4629,12 +4629,12 @@ operator(}) comment(// ------------ ) comment(// Equivalent to previously-shown code) -reserved(function) ident(inner)operator(()local_variable($x)operator(\)) +reserved(function) function(inner)operator(()local_variable($x)operator(\)) operator({) reserved(return) local_variable($x) operator(*) integer(19)operator(;) operator(}) -reserved(function) ident(outer)operator(()local_variable($arg)operator(\)) +reserved(function) function(outer)operator(()local_variable($arg)operator(\)) operator({) local_variable($x) operator(=) local_variable($arg) operator(+) integer(35)operator(;) reserved(return) local_variable($x) operator(+) ident(inner)operator(()local_variable($x)operator(\))operator(;) @@ -4714,7 +4714,7 @@ reserved(if) operator(()local_variable($pid) operator(==) operator(-)integer(1)o operator(}) reserved(elseif) operator(()local_variable($pid)operator(\)) operator({) comment(// parent catches INT and berates user) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) - reserved(function) ident(handle_sigint)operator(()local_variable($signal)operator(\)) operator({) + reserved(function) function(handle_sigint)operator(()local_variable($signal)operator(\)) operator({) predefined(echo) stringoperator(;) operator(}) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) stringoperator(\))operator(;) @@ -4770,7 +4770,7 @@ predefined(pclose)operator(()local_variable($writeme)operator(\))operator(;) comment(// -----------------------------) comment(// Output buffering callback that sends output to the pager.) -reserved(function) ident(ob_pager)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) +reserved(function) function(ob_pager)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) reserved(static) local_variable($pipe)operator(;) reserved(if) operator(()local_variable($mode) operator(&) pre_constant(PHP_OUTPUT_HANDLER_START)operator(\)) operator({) local_variable($pager) operator(=) predefined(getenv)operator(()stringoperator(\))operator(;) @@ -4793,12 +4793,12 @@ ident(ob_end_flush)operator(()operator(\))operator(;) comment(// @@PLEAC@@_16.5) comment(// Output buffering: Only display a certain number of lines of output.) -reserved(class) constant(Head) operator({) - reserved(function) constant(Head)operator(()local_variable($lines)operator(=)integer(20)operator(\)) operator({) +reserved(class) class(Head) operator({) + reserved(function) function(Head)operator(()local_variable($lines)operator(=)integer(20)operator(\)) operator({) local_variable($this)operator(->)ident(lines) operator(=) local_variable($lines)operator(;) operator(}) - reserved(function) ident(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) + reserved(function) function(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) local_variable($result) operator(=) predefined(array)operator(()operator(\))operator(;) local_variable($newline) operator(=) stringoperator(;) reserved(if) operator(()predefined(strlen)operator(()local_variable($output)operator(\)) operator(>) integer(0) operator(&&) local_variable($output)operator([)predefined(strlen)operator(()local_variable($output)operator(\)) operator(-) integer(1)operator(]) operator(==) stringoperator(\)) operator({) @@ -4816,12 +4816,12 @@ reserved(class) constant(Head) operator({) operator(}) comment(// Output buffering: Prepend line numbers to each line of output.) -reserved(class) constant(Number) operator({) - reserved(function) constant(Number)operator(()operator(\)) operator({) +reserved(class) class(Number) operator({) + reserved(function) function(Number)operator(()operator(\)) operator({) local_variable($this)operator(->)ident(line_number) operator(=) integer(0)operator(;) operator(}) - reserved(function) ident(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) + reserved(function) function(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) local_variable($result) operator(=) predefined(array)operator(()operator(\))operator(;) local_variable($newline) operator(=) stringoperator(;) reserved(if) operator(()predefined(strlen)operator(()local_variable($output)operator(\)) operator(>) integer(0) operator(&&) local_variable($output)operator([)predefined(strlen)operator(()local_variable($output)operator(\)) operator(-) integer(1)operator(]) operator(==) stringoperator(\)) operator({) @@ -4837,11 +4837,11 @@ reserved(class) constant(Number) operator({) operator(}) comment(// Output buffering: Prepend "> " to each line of output.) -reserved(class) constant(Quote) operator({) - reserved(function) constant(Quote)operator(()operator(\)) operator({) +reserved(class) class(Quote) operator({) + reserved(function) function(Quote)operator(()operator(\)) operator({) operator(}) - reserved(function) ident(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) + reserved(function) function(filter)operator(()local_variable($output)operator(,) local_variable($mode)operator(\)) operator({) local_variable($result) operator(=) predefined(array)operator(()operator(\))operator(;) local_variable($newline) operator(=) stringoperator(;) reserved(if) operator(()predefined(strlen)operator(()local_variable($output)operator(\)) operator(>) integer(0) operator(&&) local_variable($output)operator([)predefined(strlen)operator(()local_variable($output)operator(\)) operator(-) integer(1)operator(]) operator(==) stringoperator(\)) operator({) @@ -5217,7 +5217,7 @@ comment(// fifolog - read and record log msgs from fifo) local_variable($fifo) operator(=) pre_constant(null)operator(;) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) -reserved(function) ident(handle_alarm)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(handle_alarm)operator(()local_variable($signal)operator(\)) operator({) reserved(global) local_variable($fifo)operator(;) reserved(if) operator(()local_variable($fifo)operator(\)) predefined(fclose)operator(()local_variable($fifo)operator(\))operator(;) comment(// move on to the next queued process) operator(}) @@ -5287,7 +5287,7 @@ reserved(while) operator(()pre_constant(true)operator(\)) operator({) operator(}) predefined(die)operator(()stringoperator(\))operator(;) -reserved(function) ident(squabble)operator(()operator(\)) operator({) +reserved(function) function(squabble)operator(()operator(\)) operator({) reserved(global) local_variable($handle)operator(;) reserved(global) local_variable($buffer)operator(;) local_variable($i) operator(=) integer(0)operator(;) @@ -5386,7 +5386,7 @@ ident(pcntl_signal)operator(()constant(SIGQUIT)operator(,) stringoperator(\))operator(;) comment(// increment ouch for every SIGINT) -reserved(function) ident(got_sig_int)operator(()local_variable($signal)operator(\)) operator({) reserved(global) local_variable($ouch)operator(;) local_variable($ouch)operator(++)operator(;) operator(}) +reserved(function) function(got_sig_int)operator(()local_variable($signal)operator(\)) operator({) reserved(global) local_variable($ouch)operator(;) local_variable($ouch)operator(++)operator(;) operator(}) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) stringoperator(\))operator(;) comment(// ignore the signal INT) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) constant(SIG_IGN)operator(\))operator(;) @@ -5395,12 +5395,12 @@ ident(pcntl_signal)operator(()constant(SIGSTOP)operator(,) constant(SIG_DFL)oper comment(// @@PLEAC@@_16.16) comment(// the signal handler) -reserved(function) ident(ding)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(ding)operator(()local_variable($signal)operator(\)) operator({) predefined(fwrite)operator(()constant(STDERR)operator(,) stringoperator(\))operator(;) operator(}) comment(// prompt for name, overriding SIGINT) -reserved(function) ident(get_name)operator(()operator(\)) operator({) +reserved(function) function(get_name)operator(()operator(\)) operator({) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) stringoperator(\))operator(;) @@ -5421,7 +5421,7 @@ reserved(function) ident(get_name)operator(()operator(\)) operator({) operator(}) comment(// @@PLEAC@@_16.17) -reserved(function) ident(got_int)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(got_int)operator(()local_variable($signal)operator(\)) operator({) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) stringoperator(\))operator(;) comment(// but not for SIGCHLD!) comment(// ...) operator(}) @@ -5432,7 +5432,7 @@ comment(// -----------------------------) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) local_variable($interrupted) operator(=) pre_constant(false)operator(;) -reserved(function) ident(got_int)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(got_int)operator(()local_variable($signal)operator(\)) operator({) reserved(global) local_variable($interrupted)operator(;) local_variable($interrupted) operator(=) pre_constant(true)operator(;) comment(// The third argument to pcntl_signal(\) determines if system calls) @@ -5453,7 +5453,7 @@ ident(pcntl_signal)operator(()constant(SIGINT)operator(,) constant(SIG_IGN)opera comment(// install signal handler) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) -reserved(function) ident(tsktsk)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(tsktsk)operator(()local_variable($signal)operator(\)) operator({) predefined(fwrite)operator(()constant(STDERR)operator(,) stringoperator(\))operator(;) ident(pcntl_signal)operator(()constant(SIGINT)operator(,) stringoperator(\))operator(;) operator(}) @@ -5465,7 +5465,7 @@ ident(pcntl_signal)operator(()constant(SIGCHLD)operator(,) constant(SIG_IGN)oper comment(// -----------------------------) reserved(declare)operator(()ident(ticks) operator(=) integer(1)operator(\))operator(;) -reserved(function) ident(reaper)operator(()local_variable($signal)operator(\)) operator({) +reserved(function) function(reaper)operator(()local_variable($signal)operator(\)) operator({) local_variable($pid) operator(=) ident(pcntl_waitpid)operator(()operator(-)integer(1)operator(,) local_variable($status)operator(,) constant(WNOHANG)operator(\))operator(;) reserved(if) operator(()local_variable($pid) operator(>) integer(0)operator(\)) operator({) comment(// ...) @@ -5479,7 +5479,7 @@ ident(pcntl_signal)operator(()constant(SIGCHLD)operator(,) string)ident(dirs) operator(=) predefined(array)operator(()operator(\))operator(;) @@ -491,7 +491,7 @@ reserved(class) constant(Zip) reserved(extends) constant(Archive) operator({) operator(}) operator(}) -reserved(function) operator(&)ident(byref)operator(()operator(\)) operator({) +reserved(function) operator(&)function(byref)operator(()operator(\)) operator({) local_variable($x) operator(=) predefined(array)operator(()operator(\))operator(;) reserved(return) local_variable($x)operator(;) operator(}) -- cgit v1.2.1