Index: trunk/extensions/WikiScripts/i18n/Messages.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation file for extension InlineScripts. |
| 4 | + * Internationalisation file for extension WikiScripts. |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
— | — | @@ -12,43 +12,43 @@ |
13 | 13 | * @author Victor Vasiliev |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | | - 'inlinescripts-desc' => 'Provides a build into wikitext scripting language', |
| 16 | + 'wikiscripts-desc' => 'Provides a build into wikitext scripting language', |
17 | 17 | |
18 | | - 'inlinescripts-call-frommodule' => '$1::$2 called by $3::$4 at line $5', |
19 | | - 'inlinescripts-call-fromwikitext' => '$1::$2 called by wikitext', |
20 | | - 'inlinescripts-call-parse' => 'parse( "$1" )', |
| 18 | + 'wikiscripts-call-frommodule' => '$1::$2 called by $3::$4 at line $5', |
| 19 | + 'wikiscripts-call-fromwikitext' => '$1::$2 called by wikitext', |
| 20 | + 'wikiscripts-call-parse' => 'parse( "$1" )', |
21 | 21 | |
22 | | - 'inlinescripts-error' => 'Following parsing {{plural:$1|error|errors}} detected:', |
23 | | - 'inlinescripts-codelocation' => 'in module $1 at line $2', |
| 22 | + 'wikiscripts-error' => 'Following parsing {{plural:$1|error|errors}} detected:', |
| 23 | + 'wikiscripts-codelocation' => 'in module $1 at line $2', |
24 | 24 | |
25 | | - 'inlinescripts-exception-unexceptedtoken' => 'Unexpected token $2 $1: expected $3 (parser state $4)', |
26 | | - 'inlinescripts-exception-unclosedstring' => 'Unclosed string $1', |
27 | | - 'inlinescripts-exception-unrecognisedtoken' => 'Unrecognized token $1', |
28 | | - 'inlinescripts-exception-toomanytokens' => 'Exceeded tokens limit', |
29 | | - 'inlinescripts-exception-toomanyevals' => 'Exceeded evaluations limit $1', |
30 | | - 'inlinescripts-exception-recoverflow' => 'Too deep abstract syntax tree', |
31 | | - 'inlinescripts-exception-notanarray' => 'Tried to get or set an element of a non-array $1', |
32 | | - 'inlinescripts-exception-outofbounds' => 'Got out of array bounds $1', |
33 | | - 'inlinescripts-exception-notenoughargs' => 'Not enough arguments for function $1', |
34 | | - 'inlinescripts-exception-dividebyzero' => 'Division by zero $1', |
35 | | - 'inlinescripts-exception-break' => '"break" called outside of foreach $1', |
36 | | - 'inlinescripts-exception-continue' => '"continue" called outside of foreach $1', |
37 | | - 'inlinescripts-exception-emptyidx' => 'Trying to get a value of an empty index $1', |
38 | | - 'inlinescripts-exception-unknownvar' => 'Trying to use an undeclared variable $1', |
39 | | - 'inlinescripts-exception-unknownfunction' => 'Trying to use an unnknown function $2 $1', |
40 | | - 'inlinescripts-exception-notlist' => 'Trying to append an element to the end of \'\'associated\'\' array $1', |
41 | | - 'inlinescripts-exception-appendyield' => 'Trying to use append and yield in the same function $1', |
| 25 | + 'wikiscripts-exception-unexceptedtoken' => 'Unexpected token $2 $1: expected $3 (parser state $4)', |
| 26 | + 'wikiscripts-exception-unclosedstring' => 'Unclosed string $1', |
| 27 | + 'wikiscripts-exception-unrecognisedtoken' => 'Unrecognized token $1', |
| 28 | + 'wikiscripts-exception-toomanytokens' => 'Exceeded tokens limit', |
| 29 | + 'wikiscripts-exception-toomanyevals' => 'Exceeded evaluations limit $1', |
| 30 | + 'wikiscripts-exception-recoverflow' => 'Too deep abstract syntax tree', |
| 31 | + 'wikiscripts-exception-notanarray' => 'Tried to get or set an element of a non-array $1', |
| 32 | + 'wikiscripts-exception-outofbounds' => 'Got out of array bounds $1', |
| 33 | + 'wikiscripts-exception-notenoughargs' => 'Not enough arguments for function $1', |
| 34 | + 'wikiscripts-exception-dividebyzero' => 'Division by zero $1', |
| 35 | + 'wikiscripts-exception-break' => '"break" called outside of foreach $1', |
| 36 | + 'wikiscripts-exception-continue' => '"continue" called outside of foreach $1', |
| 37 | + 'wikiscripts-exception-emptyidx' => 'Trying to get a value of an empty index $1', |
| 38 | + 'wikiscripts-exception-unknownvar' => 'Trying to use an undeclared variable $1', |
| 39 | + 'wikiscripts-exception-unknownfunction' => 'Trying to use an unnknown function $2 $1', |
| 40 | + 'wikiscripts-exception-notlist' => 'Trying to append an element to the end of \'\'associated\'\' array $1', |
| 41 | + 'wikiscripts-exception-appendyield' => 'Trying to use append and yield in the same function $1', |
42 | 42 | |
43 | | - 'inlinescripts-exception-notenoughargs-user' => 'Not enough arguments for function $2::$3 $1', |
44 | | - 'inlinescripts-exception-nonexistent-module' => 'Call to non-existent module $2 $1', |
45 | | - 'inlinescripts-exception-unknownfunction-user' => 'Trying to use an unnknown user function $2::$3 $1', |
46 | | - 'inlinescripts-exception-recursion' => 'Function loop detected when calling function $2::$3 $1', |
47 | | - 'inlinescripts-exception-toodeeprecursion' => 'The maximum function nesting limit of $2 exceeded $1', |
| 43 | + 'wikiscripts-exception-notenoughargs-user' => 'Not enough arguments for function $2::$3 $1', |
| 44 | + 'wikiscripts-exception-nonexistent-module' => 'Call to non-existent module $2 $1', |
| 45 | + 'wikiscripts-exception-unknownfunction-user' => 'Trying to use an unnknown user function $2::$3 $1', |
| 46 | + 'wikiscripts-exception-recursion' => 'Function loop detected when calling function $2::$3 $1', |
| 47 | + 'wikiscripts-exception-toodeeprecursion' => 'The maximum function nesting limit of $2 exceeded $1', |
48 | 48 | |
49 | | - 'inlinescripts-transerror-notenoughargs-user' => 'Not enough arguments for function $1::$2', |
50 | | - 'inlinescripts-transerror-nonexistent-module' => 'Call to non-existent module $1', |
51 | | - 'inlinescripts-transerror-unknownfunction-user' => 'Trying to use an unnknown user function $1::$2', |
52 | | - 'inlinescripts-transerror-recursion' => 'Function loop detected when calling function $1::$2', |
53 | | - 'inlinescripts-transerror-nofunction' => 'Missing function name when invoking the script', |
54 | | - 'inlinescripts-transerror-toodeeprecursion' => 'The maximum function nesting limit of $1 exceeded', |
| 49 | + 'wikiscripts-transerror-notenoughargs-user' => 'Not enough arguments for function $1::$2', |
| 50 | + 'wikiscripts-transerror-nonexistent-module' => 'Call to non-existent module $1', |
| 51 | + 'wikiscripts-transerror-unknownfunction-user' => 'Trying to use an unnknown user function $1::$2', |
| 52 | + 'wikiscripts-transerror-recursion' => 'Function loop detected when calling function $1::$2', |
| 53 | + 'wikiscripts-transerror-nofunction' => 'Missing function name when invoking the script', |
| 54 | + 'wikiscripts-transerror-toodeeprecursion' => 'The maximum function nesting limit of $1 exceeded', |
55 | 55 | ); |
Index: trunk/extensions/WikiScripts/WikiScripts.php |
— | — | @@ -23,42 +23,42 @@ |
24 | 24 | if( !defined( 'MEDIAWIKI' ) ) |
25 | 25 | die(); |
26 | 26 | |
27 | | -$wgExtensionCredits['parserhook']['InlineScripts'] = array( |
| 27 | +$wgExtensionCredits['parserhook']['WikiScripts'] = array( |
28 | 28 | 'path' => __FILE__, |
29 | | - 'name' => 'InlineScripts', |
| 29 | + 'name' => 'WikiScripts', |
30 | 30 | 'author' => 'Victor Vasiliev', |
31 | | - 'descriptionmsg' => 'inlinescripts-desc', |
32 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:InlineScripts', |
| 31 | + 'descriptionmsg' => 'wikiscripts-desc', |
| 32 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiScripts', |
33 | 33 | ); |
34 | 34 | |
35 | 35 | $dir = dirname(__FILE__) . '/'; |
36 | | -$wgExtensionMessagesFiles['InlineScripts'] = $dir . 'i18n/Messages.php'; |
37 | | -$wgExtensionMessagesFiles['InlineScriptsMagic'] = $dir . 'i18n/Magic.php'; |
38 | | -$wgExtensionMessagesFiles['InlineScriptsNamespaces'] = $dir . 'i18n/Namespaces.php'; |
| 36 | +$wgExtensionMessagesFiles['WikiScripts'] = $dir . 'i18n/Messages.php'; |
| 37 | +$wgExtensionMessagesFiles['WikiScriptsMagic'] = $dir . 'i18n/Magic.php'; |
| 38 | +$wgExtensionMessagesFiles['WikiScriptsNamespaces'] = $dir . 'i18n/Namespaces.php'; |
39 | 39 | |
40 | | -$wgAutoloadClasses['ISHooks'] = $dir . '/Hooks.php'; |
41 | | -$wgAutoloadClasses['ISLinksUpdateHooks'] = $dir . '/LinksUpdate.php'; |
| 40 | +$wgAutoloadClasses['WSHooks'] = $dir . '/Hooks.php'; |
| 41 | +$wgAutoloadClasses['WSLinksUpdateHooks'] = $dir . '/LinksUpdate.php'; |
42 | 42 | |
43 | | -$wgAutoloadClasses['ISInterpreter'] = $dir . 'interpreter/Interpreter.php'; |
44 | | -$wgAutoloadClasses['ISScanner'] = $dir . 'interpreter/Scanner.php'; |
45 | | -$wgAutoloadClasses['ISLRParser'] = $dir . 'interpreter/LRParser.php'; |
| 43 | +$wgAutoloadClasses['WSInterpreter'] = $dir . 'interpreter/Interpreter.php'; |
| 44 | +$wgAutoloadClasses['WSScanner'] = $dir . 'interpreter/Scanner.php'; |
| 45 | +$wgAutoloadClasses['WSLRParser'] = $dir . 'interpreter/LRParser.php'; |
46 | 46 | |
47 | 47 | $wgParserTestFiles[] = $dir . 'interpreterTests.txt'; |
48 | | -$wgHooks['ParserFirstCallInit'][] = 'ISHooks::setupParserHook'; |
49 | | -$wgHooks['ParserLimitReport'][] = 'ISHooks::reportLimits'; |
50 | | -$wgHooks['ParserClearState'][] = 'ISHooks::clearState'; |
51 | | -$wgHooks['ParserTestTables'][] = 'ISHooks::addTestTables'; |
| 48 | +$wgHooks['ParserFirstCallInit'][] = 'WSHooks::setupParserHook'; |
| 49 | +$wgHooks['ParserLimitReport'][] = 'WSHooks::reportLimits'; |
| 50 | +$wgHooks['ParserClearState'][] = 'WSHooks::clearState'; |
| 51 | +$wgHooks['ParserTestTables'][] = 'WSHooks::addTestTables'; |
52 | 52 | |
53 | | -$wgHooks['CanonicalNamespaces'][] = 'ISHooks::addCanonicalNamespaces'; |
54 | | -$wgHooks['ArticleViewCustom'][] = 'ISHooks::handleScriptView'; |
55 | | -$wgHooks['TitleIsWikitextPage'][] = 'ISHooks::isWikitextPage'; |
56 | | -$wgHooks['EditFilter'][] = 'ISHooks::validateScript'; |
| 53 | +$wgHooks['CanonicalNamespaces'][] = 'WSHooks::addCanonicalNamespaces'; |
| 54 | +$wgHooks['ArticleViewCustom'][] = 'WSHooks::handleScriptView'; |
| 55 | +$wgHooks['TitleIsWikitextPage'][] = 'WSHooks::isWikitextPage'; |
| 56 | +$wgHooks['EditFilter'][] = 'WSHooks::validateScript'; |
57 | 57 | |
58 | | -$wgHooks['LinksUpdate'][] = 'ISLinksUpdateHooks::updateLinks'; |
59 | | -$wgHooks['ArticleEditUpdates'][] = 'ISLinksUpdateHooks::purgeCache'; |
60 | | -$wgHooks['ParserAfterTidy'][] = 'ISLinksUpdateHooks::appendToOutput'; |
61 | | -$wgHooks['BacklinkCacheGetPrefix'][] = 'ISLinksUpdateHooks::getBacklinkCachePrefix'; |
62 | | -$wgHooks['BacklinkCacheGetConditions'][] = 'ISLinksUpdateHooks::getBacklinkCacheConditions'; |
| 58 | +$wgHooks['LinksUpdate'][] = 'WSLinksUpdateHooks::updateLinks'; |
| 59 | +$wgHooks['ArticleEditUpdates'][] = 'WSLinksUpdateHooks::purgeCache'; |
| 60 | +$wgHooks['ParserAfterTidy'][] = 'WSLinksUpdateHooks::appendToOutput'; |
| 61 | +$wgHooks['BacklinkCacheGetPrefix'][] = 'WSLinksUpdateHooks::getBacklinkCachePrefix'; |
| 62 | +$wgHooks['BacklinkCacheGetConditions'][] = 'WSLinksUpdateHooks::getBacklinkCacheConditions'; |
63 | 63 | |
64 | 64 | /** Configuration */ |
65 | 65 | |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | /** |
78 | 78 | * Different limits of the scripts. |
79 | 79 | */ |
80 | | -$wgInlineScriptsLimits = array( |
| 80 | +$wgScriptsLimits = array( |
81 | 81 | /** |
82 | 82 | * Maximal amount of tokens (strings, keywords, numbers, operators, |
83 | 83 | * but not whitespace) in a single module to be parsed. |
— | — | @@ -101,30 +101,30 @@ |
102 | 102 | * Turn on to true if you have linked or copied wikiscripts.php and |
103 | 103 | * SyntaxHighlight_GeSHi extension is enabled. |
104 | 104 | */ |
105 | | -$wgInlineScriptsUseGeSHi = false; |
| 105 | +$wgScriptsUseGeSHi = false; |
106 | 106 | |
107 | 107 | /** |
108 | | - * Class of the actual parser. Must implement ISParser interface, as well as |
| 108 | + * Class of the actual parser. Must implement WSParser interface, as well as |
109 | 109 | * static getVersion() method. |
110 | 110 | */ |
111 | | -$wgInlineScriptsParserClass = 'ISLRParser'; |
| 111 | +$wgScriptsParserClass = 'WSLRParser'; |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Should be enabled unless you are debugging or just have sado-masochistic |
115 | 115 | * attitude towards your server. |
116 | 116 | */ |
117 | | -$wgInlineScriptsUseCache = true; |
| 117 | +$wgScriptsUseCache = true; |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Indicates whether the function recursion is enabled. If it is, then users may |
121 | 121 | * build a Turing-complete machinge and do nice things like parsers, etc in wikitext! |
122 | 122 | */ |
123 | | -$wgInlineScriptsAllowRecursion = false; |
| 123 | +$wgScriptsAllowRecursion = false; |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Maximun call stack depth. Includes functions and invokations of parse() function. |
127 | 127 | */ |
128 | | -$wgInlineScriptsMaxCallStackDepth = 25; |
| 128 | +$wgScriptsMaxCallStackDepth = 25; |
129 | 129 | |
130 | 130 | define( 'NS_MODULE', $wgScriptsNamespaceNumbers['Module'] ); |
131 | 131 | define( 'NS_MODULE_TALK', $wgScriptsNamespaceNumbers['Module_talk'] ); |
Index: trunk/extensions/WikiScripts/interpreter/Data.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | /** |
29 | 29 | * Class implementing data in the scripts. |
30 | 30 | */ |
31 | | -class ISData { |
| 31 | +class WSData { |
32 | 32 | // Data types |
33 | 33 | const DInt = 'int'; |
34 | 34 | const DString = 'string'; |
— | — | @@ -47,82 +47,82 @@ |
48 | 48 | |
49 | 49 | public static function newFromPHPVar( $var ) { |
50 | 50 | if( is_string( $var ) ) |
51 | | - return new ISData( self::DString, $var ); |
| 51 | + return new WSData( self::DString, $var ); |
52 | 52 | elseif( is_int( $var ) ) |
53 | | - return new ISData( self::DInt, $var ); |
| 53 | + return new WSData( self::DInt, $var ); |
54 | 54 | elseif( is_float( $var ) ) |
55 | | - return new ISData( self::DFloat, $var ); |
| 55 | + return new WSData( self::DFloat, $var ); |
56 | 56 | elseif( is_bool( $var ) ) |
57 | | - return new ISData( self::DBool, $var ); |
| 57 | + return new WSData( self::DBool, $var ); |
58 | 58 | elseif( is_array( $var ) ) { |
59 | 59 | if( !$var ) |
60 | | - return new ISData( self::DList, array() ); |
| 60 | + return new WSData( self::DList, array() ); |
61 | 61 | $result = array(); |
62 | 62 | foreach( $var as $item ) |
63 | 63 | $result[] = self::newFromPHPVar( $item ); |
64 | | - return new ISData( self::DList, $result ); |
| 64 | + return new WSData( self::DList, $result ); |
65 | 65 | } |
66 | 66 | elseif( is_null( $var ) ) |
67 | | - return new ISData(); |
| 67 | + return new WSData(); |
68 | 68 | else |
69 | | - throw new ISException( |
70 | | - "Data type " . gettype( $var ) . " is not supported by InlineScrtips" ); |
| 69 | + throw new WSException( |
| 70 | + "Data type " . gettype( $var ) . " is not supported by WikiScrtips" ); |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function dup() { |
74 | | - return new ISData( $this->type, $this->data ); |
| 74 | + return new WSData( $this->type, $this->data ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function castTypes( $orig, $target ) { |
78 | 78 | if( $orig->type == $target ) |
79 | 79 | return $orig->dup(); |
80 | 80 | if( $target == self::DNull ) { |
81 | | - return new ISData(); |
| 81 | + return new WSData(); |
82 | 82 | } |
83 | 83 | |
84 | 84 | if( $orig->isArray() ) { |
85 | 85 | if( $target == self::DBool ) |
86 | | - return new ISData( self::DBool, (bool)count( $orig->data ) ); |
| 86 | + return new WSData( self::DBool, (bool)count( $orig->data ) ); |
87 | 87 | if( $target == self::DFloat ) { |
88 | | - return new ISData( self::DFloat, doubleval( count( $orig->data ) ) ); |
| 88 | + return new WSData( self::DFloat, doubleval( count( $orig->data ) ) ); |
89 | 89 | } |
90 | 90 | if( $target == self::DInt ) { |
91 | | - return new ISData( self::DInt, intval( count( $orig->data ) ) ); |
| 91 | + return new WSData( self::DInt, intval( count( $orig->data ) ) ); |
92 | 92 | } |
93 | 93 | if( $target == self::DString ) { |
94 | 94 | $s = array(); |
95 | 95 | foreach( $orig->data as $item ) |
96 | 96 | $s[] = $item->toString(); |
97 | | - return new ISData( self::DString, implode( "\n", $s ) ); |
| 97 | + return new WSData( self::DString, implode( "\n", $s ) ); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | if( $target == self::DBool ) { |
102 | | - return new ISData( self::DBool, (bool)$orig->data ); |
| 102 | + return new WSData( self::DBool, (bool)$orig->data ); |
103 | 103 | } |
104 | 104 | if( $target == self::DFloat ) { |
105 | | - return new ISData( self::DFloat, doubleval( $orig->data ) ); |
| 105 | + return new WSData( self::DFloat, doubleval( $orig->data ) ); |
106 | 106 | } |
107 | 107 | if( $target == self::DInt ) { |
108 | | - return new ISData( self::DInt, intval( $orig->data ) ); |
| 108 | + return new WSData( self::DInt, intval( $orig->data ) ); |
109 | 109 | } |
110 | 110 | if( $target == self::DString ) { |
111 | | - return new ISData( self::DString, strval( $orig->data ) ); |
| 111 | + return new WSData( self::DString, strval( $orig->data ) ); |
112 | 112 | } |
113 | 113 | if( $target == self::DList ) { |
114 | | - return new ISData( self::DList, array( $orig ) ); |
| 114 | + return new WSData( self::DList, array( $orig ) ); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function boolInvert( $value ) { |
119 | | - return new ISData( self::DBool, !$value->toBool() ); |
| 119 | + return new WSData( self::DBool, !$value->toBool() ); |
120 | 120 | } |
121 | 121 | |
122 | 122 | public static function pow( $base, $exponent ) { |
123 | 123 | if( $base->type == self::DInt && $exponent->type == self::DInt ) |
124 | | - return new ISData( self::DInt, pow( $base->toInt(), $exponent->toInt() ) ); |
| 124 | + return new WSData( self::DInt, pow( $base->toInt(), $exponent->toInt() ) ); |
125 | 125 | else |
126 | | - return new ISData( self::DFloat, pow( $base->toFloat(), $exponent->toFloat() ) ); |
| 126 | + return new WSData( self::DFloat, pow( $base->toFloat(), $exponent->toFloat() ) ); |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Checks whether a is in b |
— | — | @@ -130,18 +130,18 @@ |
131 | 131 | if( $b->isArray() ) { |
132 | 132 | foreach( $b->data as $elem ) { |
133 | 133 | if( self::equals( $elem, $a ) ) |
134 | | - return new ISData( self::DBool, true ); |
| 134 | + return new WSData( self::DBool, true ); |
135 | 135 | } |
136 | | - return new ISData( self::DBool, false ); |
| 136 | + return new WSData( self::DBool, false ); |
137 | 137 | } else { |
138 | 138 | $a = $a->toString(); |
139 | 139 | $b = $b->toString(); |
140 | 140 | |
141 | 141 | if( $a == '' || $b == '' ) { |
142 | | - return new ISData( self::DBool, false ); |
| 142 | + return new WSData( self::DBool, false ); |
143 | 143 | } |
144 | 144 | |
145 | | - return new ISData( self::DBool, in_string( $a, $b ) ); |
| 145 | + return new WSData( self::DBool, in_string( $a, $b ) ); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
— | — | @@ -151,32 +151,32 @@ |
152 | 152 | |
153 | 153 | public static function unaryMinus( $data ) { |
154 | 154 | if( $data->type == self::DInt ) { |
155 | | - return new ISData( $data->type, -$data->toInt() ); |
| 155 | + return new WSData( $data->type, -$data->toInt() ); |
156 | 156 | } else { |
157 | | - return new ISData( $data->type, -$data->toFloat() ); |
| 157 | + return new WSData( $data->type, -$data->toFloat() ); |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | public static function compareOp( $a, $b, $op ) { |
162 | 162 | if( $op == '==' ) |
163 | | - return new ISData( self::DBool, self::equals( $a, $b ) ); |
| 163 | + return new WSData( self::DBool, self::equals( $a, $b ) ); |
164 | 164 | if( $op == '!=' ) |
165 | | - return new ISData( self::DBool, !self::equals( $a, $b ) ); |
| 165 | + return new WSData( self::DBool, !self::equals( $a, $b ) ); |
166 | 166 | if( $op == '===' ) |
167 | | - return new ISData( self::DBool, $a->type == $b->type && self::equals( $a, $b ) ); |
| 167 | + return new WSData( self::DBool, $a->type == $b->type && self::equals( $a, $b ) ); |
168 | 168 | if( $op == '!==' ) |
169 | | - return new ISData( self::DBool, $a->type != $b->type || !self::equals( $a, $b ) ); |
| 169 | + return new WSData( self::DBool, $a->type != $b->type || !self::equals( $a, $b ) ); |
170 | 170 | $a = $a->toString(); |
171 | 171 | $b = $b->toString(); |
172 | 172 | if( $op == '>' ) |
173 | | - return new ISData( self::DBool, $a > $b ); |
| 173 | + return new WSData( self::DBool, $a > $b ); |
174 | 174 | if( $op == '<' ) |
175 | | - return new ISData( self::DBool, $a < $b ); |
| 175 | + return new WSData( self::DBool, $a < $b ); |
176 | 176 | if( $op == '>=' ) |
177 | | - return new ISData( self::DBool, $a >= $b ); |
| 177 | + return new WSData( self::DBool, $a >= $b ); |
178 | 178 | if( $op == '<=' ) |
179 | | - return new ISData( self::DBool, $a <= $b ); |
180 | | - throw new ISException( "Invalid comparison operation: {$op}" ); // Should never happen |
| 179 | + return new WSData( self::DBool, $a <= $b ); |
| 180 | + throw new WSException( "Invalid comparison operation: {$op}" ); // Should never happen |
181 | 181 | } |
182 | 182 | |
183 | 183 | public static function mulRel( $a, $b, $op, $module, $pos ) { |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | } |
195 | 195 | |
196 | 196 | if( $op != '*' && $b == 0 ) { |
197 | | - throw new ISUserVisibleException( 'dividebyzero', $module, $pos, array($a) ); |
| 197 | + throw new WSUserVisibleException( 'dividebyzero', $module, $pos, array($a) ); |
198 | 198 | } |
199 | 199 | |
200 | 200 | $data = null; |
— | — | @@ -204,36 +204,36 @@ |
205 | 205 | elseif( $op == '%' ) |
206 | 206 | $data = $a % $b; |
207 | 207 | else |
208 | | - throw new ISException( "Invalid multiplication-related operation: {$op}" ); // Should never happen |
| 208 | + throw new WSException( "Invalid multiplication-related operation: {$op}" ); // Should never happen |
209 | 209 | |
210 | 210 | if( $type == self::DInt ) |
211 | 211 | $data = intval( $data ); |
212 | 212 | else |
213 | 213 | $data = doubleval( $data ); |
214 | 214 | |
215 | | - return new ISData( $type, $data ); |
| 215 | + return new WSData( $type, $data ); |
216 | 216 | } |
217 | 217 | |
218 | 218 | public static function sum( $a, $b ) { |
219 | 219 | if( $a->type == self::DString || $b->type == self::DString ) |
220 | | - return new ISData( self::DString, $a->toString() . $b->toString() ); |
| 220 | + return new WSData( self::DString, $a->toString() . $b->toString() ); |
221 | 221 | elseif( $a->type == self::DList && $b->type == self::DList ) |
222 | | - return new ISData( self::DList, array_merge( $a->toList(), $b->toList() ) ); |
| 222 | + return new WSData( self::DList, array_merge( $a->toList(), $b->toList() ) ); |
223 | 223 | elseif( $a->type == self::DList ) |
224 | | - return new ISData( self::DList, array_merge( $a->toList(), array( $b ) ) ); |
| 224 | + return new WSData( self::DList, array_merge( $a->toList(), array( $b ) ) ); |
225 | 225 | elseif( $a->type == self::DAssoc && $b->type == self::DAssoc ) |
226 | | - return new ISData( self::DAssoc, array_merge( $a->toAssoc(), $b->toAssoc() ) ); |
| 226 | + return new WSData( self::DAssoc, array_merge( $a->toAssoc(), $b->toAssoc() ) ); |
227 | 227 | elseif( $a->type == self::DInt && $b->type == self::DInt ) |
228 | | - return new ISData( self::DInt, $a->toInt() + $b->toInt() ); |
| 228 | + return new WSData( self::DInt, $a->toInt() + $b->toInt() ); |
229 | 229 | else |
230 | | - return new ISData( self::DFloat, $a->toFloat() + $b->toFloat() ); |
| 230 | + return new WSData( self::DFloat, $a->toFloat() + $b->toFloat() ); |
231 | 231 | } |
232 | 232 | |
233 | 233 | public static function sub( $a, $b ) { |
234 | 234 | if( $a->type == self::DInt && $b->type == self::DInt ) |
235 | | - return new ISData( self::DInt, $a->toInt() - $b->toInt() ); |
| 235 | + return new WSData( self::DInt, $a->toInt() - $b->toInt() ); |
236 | 236 | else |
237 | | - return new ISData( self::DFloat, $a->toFloat() - $b->toFloat() ); |
| 237 | + return new WSData( self::DFloat, $a->toFloat() - $b->toFloat() ); |
238 | 238 | } |
239 | 239 | |
240 | 240 | public function isArray() { |
Index: trunk/extensions/WikiScripts/interpreter/Scanner.php |
— | — | @@ -25,12 +25,12 @@ |
26 | 26 | die(); |
27 | 27 | |
28 | 28 | /** |
29 | | - * Lexical analizator for inline scripts. Splits strings to tokens. |
| 29 | + * Lexical analizator for scripts. Splits strings to tokens. |
30 | 30 | */ |
31 | 31 | |
32 | 32 | require_once( 'Shared.php' ); |
33 | 33 | |
34 | | -class ISScanner implements Iterator { |
| 34 | +class WSScanner implements Iterator { |
35 | 35 | var $mModule, $mCode, $mPos, $mCur, $mEof; |
36 | 36 | |
37 | 37 | // Order is important. The punctuation-matching regex requires that |
— | — | @@ -87,14 +87,14 @@ |
88 | 88 | } |
89 | 89 | |
90 | 90 | private function move() { |
91 | | - if( $this->mEof || ( $this->mCur && $this->mCur->type == ISToken::TEnd ) ) { |
| 91 | + if( $this->mEof || ( $this->mCur && $this->mCur->type == WSToken::TEnd ) ) { |
92 | 92 | $this->mEof = true; |
93 | 93 | return $this->mCur = null; |
94 | 94 | } |
95 | 95 | list( $val, $type ) = $this->nextToken(); |
96 | 96 | |
97 | 97 | $lineno = count( explode( "\n", substr( $this->mCode, 0, $this->mPos ) ) ); |
98 | | - return $this->mCur = new ISToken( $type, $val, $lineno ); |
| 98 | + return $this->mCur = new WSToken( $type, $val, $lineno ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | private function nextToken() { |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | $this->mPos += strlen($matches[0]); |
108 | 108 | |
109 | 109 | if( $this->mPos >= strlen($this->mCode) ) |
110 | | - return array( null, ISToken::TEnd ); |
| 110 | + return array( null, WSToken::TEnd ); |
111 | 111 | |
112 | 112 | // Comments |
113 | 113 | if ( substr($this->mCode, $this->mPos, 2) == '/*' ) { |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | if( substr( $this->mCode, $this->mPos, 2 ) == '//' ) { |
119 | 119 | $newlinePos = strpos( $this->mCode, "\n", $this->mPos ); |
120 | 120 | if( $newlinePos === false ) { |
121 | | - return array( null, ISToken::TEnd ); |
| 121 | + return array( null, WSToken::TEnd ); |
122 | 122 | } else { |
123 | 123 | $this->mPos = $newlinePos + 1; |
124 | 124 | return self::nextToken(); |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | while( $this->mPos < $strLen ) { |
134 | 134 | if( $this->mCode[$this->mPos] == $type ) { |
135 | 135 | $this->mPos++; |
136 | | - return array( $tok, ISToken::TString ); |
| 136 | + return array( $tok, WSToken::TString ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Performance: Use a PHP function (implemented in C) |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | $this->mPos++; |
180 | 180 | } |
181 | 181 | } |
182 | | - throw new ISUserVisibleException( 'unclosedstring', $this->mModule, $this->mPos, array() ); |
| 182 | + throw new WSUserVisibleException( 'unclosedstring', $this->mModule, $this->mPos, array() ); |
183 | 183 | } |
184 | 184 | |
185 | 185 | // Find operators |
— | — | @@ -252,8 +252,8 @@ |
253 | 253 | ? doubleval( $num ) |
254 | 254 | : intval( $num ), |
255 | 255 | $float |
256 | | - ? ISToken::TFloat |
257 | | - : ISToken::TInt, |
| 256 | + ? WSToken::TFloat |
| 257 | + : WSToken::TInt, |
258 | 258 | ); |
259 | 259 | } |
260 | 260 | } |
— | — | @@ -268,73 +268,73 @@ |
269 | 269 | $tok = $matches[0]; |
270 | 270 | |
271 | 271 | $type = in_array( $tok, self::$mKeywords ) |
272 | | - ? $tok : ISToken::TID; |
| 272 | + ? $tok : WSToken::TID; |
273 | 273 | |
274 | 274 | $this->mPos += strlen( $tok ); |
275 | 275 | return array( $tok, $type ); |
276 | 276 | } |
277 | 277 | |
278 | | - throw new ISUserVisibleException( |
| 278 | + throw new WSUserVisibleException( |
279 | 279 | 'unrecognisedtoken', $this->mModule, $this->mPos, array( substr( $this->mCode, $this->mPos ) ) ); |
280 | 280 | } |
281 | 281 | |
282 | 282 | private static function getOperatorType( $op ) { |
283 | 283 | switch( $op ) { |
284 | 284 | case '::': |
285 | | - return ISToken::TDoubleColon; |
| 285 | + return WSToken::TDoubleColon; |
286 | 286 | case ':': |
287 | | - return ISToken::TColon; |
| 287 | + return WSToken::TColon; |
288 | 288 | case ',': |
289 | | - return ISToken::TComma; |
| 289 | + return WSToken::TComma; |
290 | 290 | case '>': |
291 | 291 | case '<': |
292 | 292 | case '>=': |
293 | 293 | case '<=': |
294 | | - return ISToken::TCompareOperator; |
| 294 | + return WSToken::TCompareOperator; |
295 | 295 | case '==': |
296 | 296 | case '!=': |
297 | 297 | case '===': |
298 | 298 | case '!==': |
299 | | - return ISToken::TEqualsToOperator; |
| 299 | + return WSToken::TEqualsToOperator; |
300 | 300 | case '!': |
301 | | - return ISToken::TBoolInvert; |
| 301 | + return WSToken::TBoolInvert; |
302 | 302 | case '(': |
303 | | - return ISToken::TLeftBracket; |
| 303 | + return WSToken::TLeftBracket; |
304 | 304 | case '{': |
305 | | - return ISToken::TLeftCurly; |
| 305 | + return WSToken::TLeftCurly; |
306 | 306 | case '[': |
307 | | - return ISToken::TLeftSquare; |
| 307 | + return WSToken::TLeftSquare; |
308 | 308 | case '&': |
309 | 309 | case '|': |
310 | 310 | case '^': |
311 | | - return ISToken::TLogicalOperator; |
| 311 | + return WSToken::TLogicalOperator; |
312 | 312 | case '*': |
313 | 313 | case '/': |
314 | 314 | case '%': |
315 | | - return ISToken::TMulOperator; |
| 315 | + return WSToken::TMulOperator; |
316 | 316 | case '**': |
317 | | - return ISToken::TPow; |
| 317 | + return WSToken::TPow; |
318 | 318 | case ')': |
319 | | - return ISToken::TRightBracket; |
| 319 | + return WSToken::TRightBracket; |
320 | 320 | case '}': |
321 | | - return ISToken::TRightCurly; |
| 321 | + return WSToken::TRightCurly; |
322 | 322 | case ']': |
323 | | - return ISToken::TRightSquare; |
| 323 | + return WSToken::TRightSquare; |
324 | 324 | case ';': |
325 | | - return ISToken::TSemicolon; |
| 325 | + return WSToken::TSemicolon; |
326 | 326 | case '=': |
327 | 327 | case '+=': |
328 | 328 | case '-=': |
329 | 329 | case '*=': |
330 | 330 | case '/=': |
331 | | - return ISToken::TSet; |
| 331 | + return WSToken::TSet; |
332 | 332 | case '+': |
333 | 333 | case '-': |
334 | | - return ISToken::TSumOperator; |
| 334 | + return WSToken::TSumOperator; |
335 | 335 | case '?': |
336 | | - return ISToken::TTrinary; |
| 336 | + return WSToken::TTrinary; |
337 | 337 | default: |
338 | | - throw new ISException( "Invalid operator: {$op}" ); |
| 338 | + throw new WSException( "Invalid operator: {$op}" ); |
339 | 339 | } |
340 | 340 | } |
341 | 341 | } |
Index: trunk/extensions/WikiScripts/interpreter/LRParser.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * LR parser for inline scripts. |
| 5 | + * LR parser for scripts. |
6 | 6 | * Inputs tokens and LR table (ACTION/GOTO). |
7 | 7 | * Outputs parser tree. |
8 | 8 | * |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | require_once( 'LRTableVersion.php' ); |
13 | 13 | |
14 | | -class ISLRParser implements ISParser { |
| 14 | +class WSLRParser implements WSParser { |
15 | 15 | const Shift = 0; |
16 | 16 | const Reduce = 1; |
17 | 17 | const Accept = 2; |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | static $mLoaded, $mNonterminals, $mProductions, $mAction, $mGoto; |
20 | 20 | |
21 | 21 | public static function getVersion() { |
22 | | - return IS_LR_VERSION; |
| 22 | + return WS_LR_VERSION; |
23 | 23 | } |
24 | 24 | |
25 | 25 | private function loadGrammar() { |
— | — | @@ -29,10 +29,10 @@ |
30 | 30 | |
31 | 31 | require_once( 'LRTable.php' ); |
32 | 32 | |
33 | | - self::$mNonterminals = ISLRTable::$nonterminals; |
34 | | - self::$mProductions = ISLRTable::$productions; |
35 | | - self::$mAction = ISLRTable::$action; |
36 | | - self::$mGoto = ISLRTable::$goto; |
| 33 | + self::$mNonterminals = WSLRTable::$nonterminals; |
| 34 | + self::$mProductions = WSLRTable::$productions; |
| 35 | + self::$mAction = WSLRTable::$action; |
| 36 | + self::$mGoto = WSLRTable::$goto; |
37 | 37 | self::$mLoaded = true; |
38 | 38 | |
39 | 39 | wfProfileOut( __METHOD__ ); |
— | — | @@ -56,20 +56,20 @@ |
57 | 57 | $cur = $token->type; |
58 | 58 | if( !$token ) { |
59 | 59 | wfProfileOut( __METHOD__ ); |
60 | | - throw new ISException( 'Non-token input in LRParser::parse' ); |
| 60 | + throw new WSException( 'Non-token input in LRParser::parse' ); |
61 | 61 | } |
62 | 62 | |
63 | 63 | $tokenCount++; |
64 | 64 | if( $tokenCount > $maxTokens ) { |
65 | 65 | wfProfileOut( __METHOD__ ); |
66 | | - throw new ISUserVisibleException( 'toomanytokens', $module, $token->line ); |
| 66 | + throw new WSUserVisibleException( 'toomanytokens', $module, $token->line ); |
67 | 67 | } |
68 | 68 | |
69 | 69 | list( $stateval, $state ) = end( $states ); |
70 | 70 | $act = @self::$mAction[$state][$cur]; |
71 | 71 | if( !$act ) { |
72 | 72 | wfProfileOut( __METHOD__ ); |
73 | | - throw new ISUserVisibleException( 'unexceptedtoken', $module, $token->line, |
| 73 | + throw new WSUserVisibleException( 'unexceptedtoken', $module, $token->line, |
74 | 74 | array( $token, implode( ', ', array_keys( @self::$mAction[$state] ) ), $state ) ); |
75 | 75 | } |
76 | 76 | if( $act[0] == self::Shift ) { |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | $str = array_reverse( $str ); |
88 | 88 | list( $stateval, $state ) = end( $states ); |
89 | 89 | |
90 | | - $node = new ISParserTreeNode( $this, $nonterm ); |
| 90 | + $node = new WSParserTreeNode( $this, $nonterm ); |
91 | 91 | foreach( $str as $symbol ) { |
92 | 92 | list( $val ) = $symbol; |
93 | 93 | $node->addChild( $val ); |
— | — | @@ -99,13 +99,13 @@ |
100 | 100 | |
101 | 101 | wfProfileOut( __METHOD__ ); |
102 | 102 | |
103 | | - return new ISParserOutput( $states[1][0], $tokenCount ); |
| 103 | + return new WSParserOutput( $states[1][0], $tokenCount ); |
104 | 104 | } |
105 | 105 | |
106 | 106 | public function getSyntaxErrors( $input, $module, $maxTokens ) { |
107 | 107 | try { |
108 | 108 | $this->parse( $input, $module, $maxTokens ); |
109 | | - } catch( ISUserVisibleException $e ) { |
| 109 | + } catch( WSUserVisibleException $e ) { |
110 | 110 | return array( $e->getMessage() ); |
111 | 111 | } |
112 | 112 | |
Index: trunk/extensions/WikiScripts/interpreter/LRTableVersion.php |
— | — | @@ -6,4 +6,4 @@ |
7 | 7 | * version in separate file. |
8 | 8 | */ |
9 | 9 | |
10 | | -define( 'IS_LR_VERSION', "2011-08-13 21:53:42" ); |
| 10 | +define( 'WS_LR_VERSION', "2011-08-13 21:53:42" ); |
Index: trunk/extensions/WikiScripts/interpreter/EvaluationContext.php |
— | — | @@ -24,12 +24,12 @@ |
25 | 25 | die(); |
26 | 26 | |
27 | 27 | /** |
28 | | - * An internal class used by InlineScript. Used to evaluate a parsed code |
| 28 | + * An internal class used by WikiScripts. Used to evaluate a parsed code |
29 | 29 | * in a sepereate context with its own output, variables and parser frame. |
30 | 30 | * |
31 | 31 | * Handles evaluation of an individual functions. |
32 | 32 | */ |
33 | | -class ISEvaluationContext { |
| 33 | +class WSEvaluationContext { |
34 | 34 | var $mVars, $mFrame, $mName, $mInterpreter, $mModule; |
35 | 35 | |
36 | 36 | var $mOutput, $mListOutput; |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $this->mParser = $interpreter->getParser(); |
77 | 77 | $this->mFrame = $frame; |
78 | 78 | |
79 | | - $this->mOutput = new ISData(); |
| 79 | + $this->mOutput = new WSData(); |
80 | 80 | $this->mListOutput = array(); |
81 | 81 | } |
82 | 82 | |
— | — | @@ -88,12 +88,12 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | public function getOutput() { |
92 | | - if( $this->mOutput->type != ISData::DNull ) { |
| 92 | + if( $this->mOutput->type != WSData::DNull ) { |
93 | 93 | return $this->mOutput; |
94 | 94 | } elseif( $this->mListOutput ) { |
95 | | - return new ISData( ISData::DList, $this->mListOutput ); |
| 95 | + return new WSData( WSData::DList, $this->mListOutput ); |
96 | 96 | } else { |
97 | | - return new ISData(); |
| 97 | + return new WSData(); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
— | — | @@ -107,12 +107,12 @@ |
108 | 108 | * recursively. |
109 | 109 | */ |
110 | 110 | public function evaluateNode( $node, $rec ) { |
111 | | - if( !$node instanceof ISParserTreeNode ) { |
112 | | - throw new ISException( 'evaluateNode() accepts only nonterminals' ); |
| 111 | + if( !$node instanceof WSParserTreeNode ) { |
| 112 | + throw new WSException( 'evaluateNode() accepts only nonterminals' ); |
113 | 113 | } |
114 | 114 | |
115 | 115 | if( !$this->mInterpreter->checkRecursionLimit( $rec ) ) { |
116 | | - throw new ISUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
| 116 | + throw new WSUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $c = $node->getChildren(); |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | $res = $this->evaluateNode( $stmt, $rec + 1 ); |
130 | 130 | return $res; |
131 | 131 | case 'stmt': |
132 | | - if( $c[0] instanceof ISToken ) { |
| 132 | + if( $c[0] instanceof WSToken ) { |
133 | 133 | switch( $c[0]->type ) { |
134 | 134 | case 'leftcurly': |
135 | 135 | return $this->evaluateNode( $c[1], $rec + 1 ); |
— | — | @@ -140,27 +140,27 @@ |
141 | 141 | if( isset( $c[6] ) ) { |
142 | 142 | return $this->evaluateNode( $c[6], $rec + 1 ); |
143 | 143 | } else { |
144 | | - return new ISData(); |
| 144 | + return new WSData(); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | case 'for': |
148 | 148 | $array = $this->evaluateNode( $c[4], $rec + 1 ); |
149 | 149 | if( !$array->isArray() ) |
150 | | - throw new ISUserVisibleException( 'invalidforeach', $this->mModuleName, $c[0]->line ); |
151 | | - $last = new ISData(); |
| 150 | + throw new WSUserVisibleException( 'invalidforeach', $this->mModuleName, $c[0]->line ); |
| 151 | + $last = new WSData(); |
152 | 152 | $lvalues = $c[2]->getChildren(); |
153 | 153 | |
154 | 154 | foreach( $array->data as $key => $item ) { |
155 | 155 | // <forlvalue> ::= <lvalue> | <lvalue> colon <lvalue> |
156 | 156 | if( count( $lvalues ) > 1 ) { |
157 | | - $this->setVar( $lvalues[0], ISData::newFromPHPVar( $key ), $rec ); |
| 157 | + $this->setVar( $lvalues[0], WSData::newFromPHPVar( $key ), $rec ); |
158 | 158 | $this->setVar( $lvalues[2], $item, $rec ); |
159 | 159 | } else { |
160 | 160 | $this->setVar( $lvalues[0], $item, $rec ); |
161 | 161 | } |
162 | 162 | try { |
163 | 163 | $last = $this->evaluateNode( $c[6], $rec + 1 ); |
164 | | - } catch( ISUserVisibleException $e ) { |
| 164 | + } catch( WSUserVisibleException $e ) { |
165 | 165 | if( $e->getExceptionID() == 'break' ) |
166 | 166 | break; |
167 | 167 | elseif( $e->getExceptionID() == 'continue' ) |
— | — | @@ -173,16 +173,16 @@ |
174 | 174 | case 'try': |
175 | 175 | try { |
176 | 176 | return $this->evaluateNode( $c[1], $rec + 1 ); |
177 | | - } catch( ISUserVisibleException $e ) { |
178 | | - if( $e instanceof ISControlException ) { |
| 177 | + } catch( WSUserVisibleException $e ) { |
| 178 | + if( $e instanceof WSControlException ) { |
179 | 179 | throw $e; |
180 | 180 | } else { |
181 | | - $this->setVar( $c[4], new ISData( ISData::DString, $e->getExceptionID() ), $rec ); |
| 181 | + $this->setVar( $c[4], new WSData( WSData::DString, $e->getExceptionID() ), $rec ); |
182 | 182 | return $this->evaluateNode( $c[6], $rec + 1 ); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | default: |
186 | | - throw new ISException( "Unknown keyword: {$c[0]->type}" ); |
| 186 | + throw new WSException( "Unknown keyword: {$c[0]->type}" ); |
187 | 187 | } |
188 | 188 | } else { |
189 | 189 | return $this->evaluateNode( $c[0], $rec + 1 ); |
— | — | @@ -194,26 +194,26 @@ |
195 | 195 | $retval = $this->evaluateNode( $c[1], $rec + 1 ); |
196 | 196 | $empty = false; |
197 | 197 | } else { |
198 | | - $retval = new ISData(); |
| 198 | + $retval = new WSData(); |
199 | 199 | $empty = true; |
200 | 200 | } |
201 | | - throw new ISReturnException( $retval, $empty ); |
| 201 | + throw new WSReturnException( $retval, $empty ); |
202 | 202 | case 'append': |
203 | 203 | if( $this->mListOutput ) { |
204 | | - throw new ISUserVisibleException( 'appendyield', $this->mModuleName, $c[0]->line ); |
| 204 | + throw new WSUserVisibleException( 'appendyield', $this->mModuleName, $c[0]->line ); |
205 | 205 | } |
206 | 206 | |
207 | | - $this->mOutput = ISData::sum( $this->mOutput, $this->evaluateNode( $c[1], $rec + 1 ) ); |
| 207 | + $this->mOutput = WSData::sum( $this->mOutput, $this->evaluateNode( $c[1], $rec + 1 ) ); |
208 | 208 | break 2; |
209 | 209 | case 'yield': |
210 | | - if( $this->mOutput->type != ISData::DNull ) { |
211 | | - throw new ISUserVisibleException( 'appendyield', $this->mModuleName, $c[0]->line ); |
| 210 | + if( $this->mOutput->type != WSData::DNull ) { |
| 211 | + throw new WSUserVisibleException( 'appendyield', $this->mModuleName, $c[0]->line ); |
212 | 212 | } |
213 | 213 | |
214 | 214 | $this->mListOutput[] = $this->evaluateNode( $c[1], $rec + 1 ); |
215 | 215 | break 2; |
216 | 216 | default: |
217 | | - throw new ISException( "Unknown return keyword: {$c[0]->value}" ); |
| 217 | + throw new WSException( "Unknown return keyword: {$c[0]->value}" ); |
218 | 218 | } |
219 | 219 | case 'exprset': |
220 | 220 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
— | — | @@ -242,67 +242,67 @@ |
243 | 243 | switch( $c[1]->value ) { |
244 | 244 | case '&': |
245 | 245 | if( !$arg1->toBool() ) |
246 | | - return new ISData( ISData::DBool, false ); |
| 246 | + return new WSData( WSData::DBool, false ); |
247 | 247 | else |
248 | 248 | return $this->evaluateNode( $c[2], $rec + 1 ); |
249 | 249 | case '|': |
250 | 250 | if( $arg1->toBool() ) |
251 | | - return new ISData( ISData::DBool, true ); |
| 251 | + return new WSData( WSData::DBool, true ); |
252 | 252 | else |
253 | 253 | return $this->evaluateNode( $c[2], $rec + 1 ); |
254 | 254 | case '^': |
255 | 255 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
256 | | - return new ISData( ISData::DBool, $arg1->toBool() xor $arg2->toBool() ); |
| 256 | + return new WSData( WSData::DBool, $arg1->toBool() xor $arg2->toBool() ); |
257 | 257 | default: |
258 | | - throw new ISException( "Invalid logical operation: {$c[1]->value}" ); |
| 258 | + throw new WSException( "Invalid logical operation: {$c[1]->value}" ); |
259 | 259 | } |
260 | 260 | case 'exprequals': |
261 | 261 | case 'exprcompare': |
262 | 262 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
263 | 263 | $arg1 = $this->evaluateNode( $c[0], $rec + 1 ); |
264 | 264 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
265 | | - return ISData::compareOp( $arg1, $arg2, $c[1]->value ); |
| 265 | + return WSData::compareOp( $arg1, $arg2, $c[1]->value ); |
266 | 266 | case 'exprsum': |
267 | 267 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
268 | 268 | $arg1 = $this->evaluateNode( $c[0], $rec + 1 ); |
269 | 269 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
270 | 270 | switch( $c[1]->value ) { |
271 | 271 | case '+': |
272 | | - return ISData::sum( $arg1, $arg2 ); |
| 272 | + return WSData::sum( $arg1, $arg2 ); |
273 | 273 | case '-': |
274 | | - return ISData::sub( $arg1, $arg2 ); |
| 274 | + return WSData::sub( $arg1, $arg2 ); |
275 | 275 | } |
276 | 276 | case 'exprmul': |
277 | 277 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
278 | 278 | $arg1 = $this->evaluateNode( $c[0], $rec + 1 ); |
279 | 279 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
280 | | - return ISData::mulRel( $arg1, $arg2, $c[1]->value, $this->mModuleName, $c[1]->line ); |
| 280 | + return WSData::mulRel( $arg1, $arg2, $c[1]->value, $this->mModuleName, $c[1]->line ); |
281 | 281 | case 'exprpow': |
282 | 282 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
283 | 283 | $arg1 = $this->evaluateNode( $c[0], $rec + 1 ); |
284 | 284 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
285 | | - return ISData::pow( $arg1, $arg2 ); |
| 285 | + return WSData::pow( $arg1, $arg2 ); |
286 | 286 | case 'exprkeyword': |
287 | 287 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
288 | 288 | $arg1 = $this->evaluateNode( $c[0], $rec + 1 ); |
289 | 289 | $arg2 = $this->evaluateNode( $c[2], $rec + 1 ); |
290 | 290 | switch( $c[1]->value ) { |
291 | 291 | case 'in': |
292 | | - return ISData::keywordIn( $arg1, $arg2 ); |
| 292 | + return WSData::keywordIn( $arg1, $arg2 ); |
293 | 293 | case 'contains': |
294 | | - return ISData::keywordIn( $arg2, $arg1 ); |
| 294 | + return WSData::keywordIn( $arg2, $arg1 ); |
295 | 295 | default: |
296 | | - throw new ISException( "Invalid keyword: {$c[1]->value}" ); |
| 296 | + throw new WSException( "Invalid keyword: {$c[1]->value}" ); |
297 | 297 | } |
298 | 298 | case 'exprinvert': |
299 | 299 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[0]->line ); |
300 | 300 | $arg = $this->evaluateNode( $c[1], $rec + 1 ); |
301 | | - return ISData::boolInvert( $arg ); |
| 301 | + return WSData::boolInvert( $arg ); |
302 | 302 | case 'exprunary': |
303 | 303 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[0]->line ); |
304 | 304 | $arg = $this->evaluateNode( $c[1], $rec + 1 ); |
305 | 305 | if( $c[0]->value == '-' ) |
306 | | - return ISData::unaryMinus( $arg ); |
| 306 | + return WSData::unaryMinus( $arg ); |
307 | 307 | else |
308 | 308 | return $arg; |
309 | 309 | case 'exprfunction': |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | |
315 | 315 | $this->mInterpreter->increaseEvaluationsCount( $this->mModuleName, $c[1]->line ); |
316 | 316 | if( $c[0]->getType() == 'funcid' ) { |
317 | | - if( $c[2] instanceof ISParserTreeNode ) { |
| 317 | + if( $c[2] instanceof WSParserTreeNode ) { |
318 | 318 | $args = $this->parseArray( $c[2], $rec, $dummy ); |
319 | 319 | } else { |
320 | 320 | $args = array(); |
— | — | @@ -323,12 +323,12 @@ |
324 | 324 | if( count( $idch ) == 1 ) { |
325 | 325 | $funcname = $idch[0]->value; |
326 | 326 | if( !isset( self::$mFunctions[$funcname] ) ) |
327 | | - throw new ISUserVisibleException( 'unknownfunction', $this->mModuleName, $idch[0]->line, array( $funcname ) ); |
| 327 | + throw new WSUserVisibleException( 'unknownfunction', $this->mModuleName, $idch[0]->line, array( $funcname ) ); |
328 | 328 | $func = self::$mFunctions[$funcname]; |
329 | 329 | return $this->$func( $args, $idch[0]->line ); |
330 | 330 | } else { |
331 | 331 | $funcname = $idch[2]->value; |
332 | | - if( $idch[0] instanceof ISToken ) { |
| 332 | + if( $idch[0] instanceof WSToken ) { |
333 | 333 | // self::function() |
334 | 334 | $module = $this->mModule; |
335 | 335 | } else { |
— | — | @@ -343,31 +343,31 @@ |
344 | 344 | switch( $type ) { |
345 | 345 | case 'isset': |
346 | 346 | $val = $this->getVar( $c[2], $rec, true ); |
347 | | - return new ISData( ISData::DBool, $val !== null ); |
| 347 | + return new WSData( WSData::DBool, $val !== null ); |
348 | 348 | case 'delete': |
349 | 349 | $this->deleteVar( $c[2], $rec ); |
350 | | - return new ISData(); |
| 350 | + return new WSData(); |
351 | 351 | default: |
352 | | - throw new ISException( "Unknown keyword: {$type}" ); |
| 352 | + throw new WSException( "Unknown keyword: {$type}" ); |
353 | 353 | } |
354 | 354 | } |
355 | 355 | case 'expratom': |
356 | | - if( $c[0] instanceof ISParserTreeNode ) { |
| 356 | + if( $c[0] instanceof WSParserTreeNode ) { |
357 | 357 | if( $c[0]->getType() == 'atom' ) { |
358 | 358 | list( $val ) = $c[0]->getChildren(); |
359 | 359 | switch( $val->type ) { |
360 | 360 | case 'string': |
361 | | - return new ISData( ISData::DString, $val->value ); |
| 361 | + return new WSData( WSData::DString, $val->value ); |
362 | 362 | case 'int': |
363 | | - return new ISData( ISData::DInt, $val->value ); |
| 363 | + return new WSData( WSData::DInt, $val->value ); |
364 | 364 | case 'float': |
365 | | - return new ISData( ISData::DFloat, $val->value ); |
| 365 | + return new WSData( WSData::DFloat, $val->value ); |
366 | 366 | case 'true': |
367 | | - return new ISData( ISData::DBool, true ); |
| 367 | + return new WSData( WSData::DBool, true ); |
368 | 368 | case 'false': |
369 | | - return new ISData( ISData::DBool, false ); |
| 369 | + return new WSData( WSData::DBool, false ); |
370 | 370 | case 'null': |
371 | | - return new ISData(); |
| 371 | + return new WSData(); |
372 | 372 | } |
373 | 373 | } else { |
374 | 374 | return $this->getVar( $c[0], $rec ); |
— | — | @@ -380,16 +380,16 @@ |
381 | 381 | case 'leftcurly': |
382 | 382 | $arraytype = null; |
383 | 383 | $array = $this->parseArray( $c[1], $rec + 1, $arraytype ); |
384 | | - return new ISData( $arraytype, $array ); |
| 384 | + return new WSData( $arraytype, $array ); |
385 | 385 | case 'break': |
386 | | - throw new ISControlException( 'break', $this->mModuleName, $c[0]->line ); |
| 386 | + throw new WSControlException( 'break', $this->mModuleName, $c[0]->line ); |
387 | 387 | case 'continue': |
388 | | - throw new ISControlException( 'continue', $this->mModuleName, $c[0]->line ); |
| 388 | + throw new WSControlException( 'continue', $this->mModuleName, $c[0]->line ); |
389 | 389 | } |
390 | 390 | } |
391 | 391 | default: |
392 | 392 | $type = $node->getType(); |
393 | | - throw new ISException( "Invalid node type passed to evaluateNode(): {$type}" ); |
| 393 | + throw new WSException( "Invalid node type passed to evaluateNode(): {$type}" ); |
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
— | — | @@ -419,7 +419,7 @@ |
420 | 420 | $result[] = $this->evaluateNode( $elem, $rec + 1 ); |
421 | 421 | } |
422 | 422 | |
423 | | - $arraytype = ISData::DList; |
| 423 | + $arraytype = WSData::DList; |
424 | 424 | wfProfileOut( __METHOD__ ); |
425 | 425 | return $result; |
426 | 426 | |
— | — | @@ -432,7 +432,7 @@ |
433 | 433 | $result[ $key->toString() ] = $value; |
434 | 434 | } |
435 | 435 | |
436 | | - $arraytype = ISData::DAssoc; |
| 436 | + $arraytype = WSData::DAssoc; |
437 | 437 | wfProfileOut( __METHOD__ ); |
438 | 438 | return $result; |
439 | 439 | } |
— | — | @@ -447,18 +447,18 @@ |
448 | 448 | // <arrayIdx> ::= leftsquare <expr> rightsquare | leftsquare rightsquare |
449 | 449 | |
450 | 450 | if( !$this->mInterpreter->checkRecursionLimit( $rec ) ) { |
451 | | - throw new ISUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
| 451 | + throw new WSUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | $c = $lval->getChildren(); |
455 | | - if( $c[0] instanceof ISToken ) { |
| 455 | + if( $c[0] instanceof WSToken ) { |
456 | 456 | // Variable ID |
457 | 457 | $varname = $c[0]->value; |
458 | 458 | if( !isset( $this->mVars[$varname] ) ) { |
459 | 459 | if( $nullIfNotSet ) |
460 | 460 | return null; |
461 | 461 | else |
462 | | - throw new ISUserVisibleException( 'unknownvar', $this->mModuleName, $c[0]->line, array( $varname ) ); |
| 462 | + throw new WSUserVisibleException( 'unknownvar', $this->mModuleName, $c[0]->line, array( $varname ) ); |
463 | 463 | } |
464 | 464 | return $this->mVars[$varname]; |
465 | 465 | } else { |
— | — | @@ -470,30 +470,30 @@ |
471 | 471 | |
472 | 472 | if( count( $idxchildren ) == 2 ) { |
473 | 473 | // x = a[]. a[] is still legitimage in a[] = x |
474 | | - throw new ISUserVisibleException( 'emptyidx', $this->mModuleName, $idxchildren[0]->line ); |
| 474 | + throw new WSUserVisibleException( 'emptyidx', $this->mModuleName, $idxchildren[0]->line ); |
475 | 475 | } |
476 | 476 | |
477 | 477 | switch( $var->type ) { |
478 | | - case ISData::DList: |
| 478 | + case WSData::DList: |
479 | 479 | $idx = $this->evaluateNode( $idxchildren[1], $rec + 1 )->toInt(); |
480 | 480 | if( $idx >= count( $var->data ) ) { |
481 | 481 | if( $nullIfNotSet ) |
482 | 482 | return null; |
483 | 483 | else |
484 | | - throw new ISUserVisibleException( 'outofbounds', $this->mModuleName, $idxchildren[0]->line ); |
| 484 | + throw new WSUserVisibleException( 'outofbounds', $this->mModuleName, $idxchildren[0]->line ); |
485 | 485 | } |
486 | 486 | return $var->data[$idx]; |
487 | | - case ISData::DAssoc: |
| 487 | + case WSData::DAssoc: |
488 | 488 | $idx = $this->evaluateNode( $idxchildren[1], $rec + 1 )->toString(); |
489 | 489 | if( !isset( $var->data[$idx] ) ) { |
490 | 490 | if( $nullIfNotSet ) |
491 | 491 | return null; |
492 | 492 | else |
493 | | - throw new ISUserVisibleException( 'outofbounds', $this->mModuleName, $idxchildren[0]->line ); |
| 493 | + throw new WSUserVisibleException( 'outofbounds', $this->mModuleName, $idxchildren[0]->line ); |
494 | 494 | } |
495 | 495 | return $var->data[$idx]; |
496 | 496 | default: |
497 | | - throw new ISUserVisibleException( 'notanarray', $this->mModuleName, $idxchildren[0]->line ); |
| 497 | + throw new WSUserVisibleException( 'notanarray', $this->mModuleName, $idxchildren[0]->line ); |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
— | — | @@ -502,7 +502,7 @@ |
503 | 503 | * Gets the line of the first terminal in the node. |
504 | 504 | */ |
505 | 505 | protected function getLine( $node ) { |
506 | | - while( $node instanceof ISParserTreeNode ) { |
| 506 | + while( $node instanceof WSParserTreeNode ) { |
507 | 507 | $children = $node->getChildren(); |
508 | 508 | $node = $children[0]; |
509 | 509 | } |
— | — | @@ -524,59 +524,59 @@ |
525 | 525 | */ |
526 | 526 | protected function &setVarGetRef( $lval, $rec ) { |
527 | 527 | if( !$this->mInterpreter->checkRecursionLimit( $rec ) ) { |
528 | | - throw new ISUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
| 528 | + throw new WSUserVisibleException( 'recoverflow', $this->mModuleName, $this->getLine( $node ) ); |
529 | 529 | } |
530 | 530 | |
531 | 531 | $c = $lval->getChildren(); |
532 | 532 | if( count( $c ) == 1 ) { |
533 | 533 | if( !isset( $this->mVars[ $c[0]->value ] ) ) |
534 | | - $this->mVars[ $c[0]->value ] = new ISPlaceholder(); |
| 534 | + $this->mVars[ $c[0]->value ] = new WSPlaceholder(); |
535 | 535 | return $this->mVars[ $c[0]->value ]; |
536 | 536 | } else { |
537 | 537 | $ref = &$this->setVarGetRef( $c[0], $rec + 1 ); |
538 | 538 | |
539 | 539 | // <arrayIdx> ::= leftsquare <expr> rightsquare | leftsquare rightsquare |
540 | 540 | $idxc = $c[1]->getChildren(); |
541 | | - if( $ref instanceof ISPlaceholder ) { |
| 541 | + if( $ref instanceof WSPlaceholder ) { |
542 | 542 | if( count( $idxc ) > 2 ) { |
543 | 543 | $index = $this->evaluateNode( $idxc[1], $rec + 1 ); |
544 | | - $ref = new ISData( ISData::DAssoc, array() ); |
| 544 | + $ref = new WSData( WSData::DAssoc, array() ); |
545 | 545 | } else { |
546 | | - $ref = new ISData( ISData::DList, array() ); |
| 546 | + $ref = new WSData( WSData::DList, array() ); |
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | 550 | switch( $ref->type ) { |
551 | | - case ISData::DList: |
| 551 | + case WSData::DList: |
552 | 552 | if( count( $idxc ) > 2 ) { |
553 | 553 | $index = $this->evaluateNode( $idxc[1], $rec + 1 ); |
554 | 554 | $key = $index->toInt(); |
555 | 555 | |
556 | 556 | if( $key < 0 || $key > count( $ref->data ) ) |
557 | | - throw new ISUserVisibleException( 'outofbounds', $this->mModuleName, $idxc[0]->line ); |
| 557 | + throw new WSUserVisibleException( 'outofbounds', $this->mModuleName, $idxc[0]->line ); |
558 | 558 | } else { |
559 | 559 | $key = count( $ref->data ); |
560 | 560 | } |
561 | 561 | |
562 | 562 | if( !isset( $ref->data[$key] ) ) |
563 | | - $ref->data[$key] = new ISPlaceholder(); |
| 563 | + $ref->data[$key] = new WSPlaceholder(); |
564 | 564 | |
565 | 565 | return $ref->data[$key]; |
566 | | - case ISData::DAssoc: |
| 566 | + case WSData::DAssoc: |
567 | 567 | if( count( $idxc ) > 2 ) { |
568 | 568 | if( !isset( $index ) ) |
569 | 569 | $index = $this->evaluateNode( $idxc[1], $rec + 1 ); |
570 | 570 | $key = $index->toString(); |
571 | 571 | |
572 | 572 | if( !isset( $ref->data[$key] ) ) |
573 | | - $ref->data[$key] = new ISPlaceholder(); |
| 573 | + $ref->data[$key] = new WSPlaceholder(); |
574 | 574 | return $ref->data[$key]; |
575 | 575 | } else { |
576 | | - throw new ISUserVisibleException( 'notlist', $this->mModuleName, $idxc[0]->line ); |
| 576 | + throw new WSUserVisibleException( 'notlist', $this->mModuleName, $idxc[0]->line ); |
577 | 577 | } |
578 | 578 | break; |
579 | 579 | default: |
580 | | - throw new ISUserVisibleException( 'notanarray', $this->mModuleName, $idxc[0]->line ); |
| 580 | + throw new WSUserVisibleException( 'notanarray', $this->mModuleName, $idxc[0]->line ); |
581 | 581 | } |
582 | 582 | } |
583 | 583 | } |
— | — | @@ -584,13 +584,13 @@ |
585 | 585 | protected function getValueForSetting( $old, $new, $set, $line ) { |
586 | 586 | switch( $set ) { |
587 | 587 | case '+=': |
588 | | - return ISData::sum( $old, $new ); |
| 588 | + return WSData::sum( $old, $new ); |
589 | 589 | case '-=': |
590 | | - return ISData::sub( $old, $new ); |
| 590 | + return WSData::sub( $old, $new ); |
591 | 591 | case '*=': |
592 | | - return ISData::mulRel( $old, $new, '*', $line ); |
| 592 | + return WSData::mulRel( $old, $new, '*', $line ); |
593 | 593 | case '/=': |
594 | | - return ISData::mulRel( $old, $new, '/', $line ); |
| 594 | + return WSData::mulRel( $old, $new, '/', $line ); |
595 | 595 | default: |
596 | 596 | return $new; |
597 | 597 | } |
— | — | @@ -598,7 +598,7 @@ |
599 | 599 | |
600 | 600 | protected function checkParamsCount( $args, $pos, $count ) { |
601 | 601 | if( count( $args ) < $count ) |
602 | | - throw new ISUserVisibleException( 'notenoughargs', $this->mModuleName, $pos ); |
| 602 | + throw new WSUserVisibleException( 'notenoughargs', $this->mModuleName, $pos ); |
603 | 603 | } |
604 | 604 | |
605 | 605 | protected function deleteVar( $lval, $rec ) { |
— | — | @@ -606,7 +606,7 @@ |
607 | 607 | $line = $c[0]->line; |
608 | 608 | $varname = $c[0]->value; |
609 | 609 | if( isset( $c[1] ) ) { |
610 | | - throw new ISException( 'delete() is not usable for array elements' ); |
| 610 | + throw new WSException( 'delete() is not usable for array elements' ); |
611 | 611 | } |
612 | 612 | unset( $this->mVars[$varname] ); |
613 | 613 | } |
— | — | @@ -616,19 +616,19 @@ |
617 | 617 | $this->checkParamsCount( $args, $pos, 1 ); |
618 | 618 | |
619 | 619 | $argName = $args[0]->toString(); |
620 | | - $default = isset( $args[1] ) ? $args[1] : new ISData(); |
| 620 | + $default = isset( $args[1] ) ? $args[1] : new WSData(); |
621 | 621 | if( $this->mFrame->getArgument( $argName ) === false ) |
622 | 622 | return $default; |
623 | 623 | else |
624 | | - return new ISData( ISData::DString, $this->mFrame->getArgument( $argName ) ); |
| 624 | + return new WSData( WSData::DString, $this->mFrame->getArgument( $argName ) ); |
625 | 625 | } |
626 | 626 | |
627 | 627 | protected function funcArgs( $args, $pos ) { |
628 | | - return ISData::newFromPHPVar( $this->mFrame->getNumberedArguments() ); |
| 628 | + return WSData::newFromPHPVar( $this->mFrame->getNumberedArguments() ); |
629 | 629 | } |
630 | 630 | |
631 | 631 | protected function funcIsTranscluded( $args, $pos ) { |
632 | | - return new ISData( ISData::DBool, $this->mFrame->isTemplate() ); |
| 632 | + return new WSData( WSData::DBool, $this->mFrame->isTemplate() ); |
633 | 633 | } |
634 | 634 | |
635 | 635 | protected function funcParse( $args, $pos ) { |
— | — | @@ -644,30 +644,30 @@ |
645 | 645 | $this->mParser->setOutputType( $oldOT ); |
646 | 646 | |
647 | 647 | $this->mInterpreter->mCallStack->pop(); |
648 | | - return new ISData( ISData::DString, $parsed ); |
| 648 | + return new WSData( WSData::DString, $parsed ); |
649 | 649 | } |
650 | 650 | |
651 | 651 | protected function funcLc( $args, $pos ) { |
652 | 652 | global $wgContLang; |
653 | 653 | $this->checkParamsCount( $args, $pos, 1 ); |
654 | | - return new ISData( ISData::DString, $wgContLang->lc( $args[0]->toString() ) ); |
| 654 | + return new WSData( WSData::DString, $wgContLang->lc( $args[0]->toString() ) ); |
655 | 655 | } |
656 | 656 | |
657 | 657 | protected function funcUc( $args, $pos ) { |
658 | 658 | global $wgContLang; |
659 | 659 | $this->checkParamsCount( $args, $pos, 1 ); |
660 | | - return new ISData( ISData::DString, $wgContLang->uc( $args[0]->toString() ) ); |
| 660 | + return new WSData( WSData::DString, $wgContLang->uc( $args[0]->toString() ) ); |
661 | 661 | } |
662 | 662 | |
663 | 663 | protected function funcUcFirst( $args, $pos ) { |
664 | 664 | global $wgContLang; |
665 | 665 | $this->checkParamsCount( $args, $pos, 1 ); |
666 | | - return new ISData( ISData::DString, $wgContLang->ucfirst( $args[0]->toString() ) ); |
| 666 | + return new WSData( WSData::DString, $wgContLang->ucfirst( $args[0]->toString() ) ); |
667 | 667 | } |
668 | 668 | |
669 | 669 | protected function funcUrlencode( $args, $pos ) { |
670 | 670 | $this->checkParamsCount( $args, $pos, 1 ); |
671 | | - return new ISData( ISData::DString, urlencode( $args[0]->toString() ) ); |
| 671 | + return new WSData( WSData::DString, urlencode( $args[0]->toString() ) ); |
672 | 672 | } |
673 | 673 | |
674 | 674 | protected function funcAnchorEncode( $args, $pos ) { |
— | — | @@ -677,7 +677,7 @@ |
678 | 678 | $s = strtr( $s, array( '%' => '.', '+' => '_' ) ); |
679 | 679 | $s = str_replace( '.3A', ':', $s ); |
680 | 680 | |
681 | | - return new ISData( ISData::DString, $s ); |
| 681 | + return new WSData( WSData::DString, $s ); |
682 | 682 | } |
683 | 683 | |
684 | 684 | protected function funcGrammar( $args, $pos ) { |
— | — | @@ -685,7 +685,7 @@ |
686 | 686 | list( $case, $word ) = $args; |
687 | 687 | $res = $this->mParser->getFunctionLang()->convertGrammar( |
688 | 688 | $word->toString(), $case->toString() ); |
689 | | - return new ISData( ISData::DString, $res ); |
| 689 | + return new WSData( WSData::DString, $res ); |
690 | 690 | } |
691 | 691 | |
692 | 692 | protected function funcPlural( $args, $pos ) { |
— | — | @@ -694,12 +694,12 @@ |
695 | 695 | for( $i = 1; $i < count( $args ); $i++ ) |
696 | 696 | $forms[] = $args[$i]->toString(); |
697 | 697 | $res = $this->mParser->getFunctionLang()->convertPlural( $num, $forms ); |
698 | | - return new ISData( ISData::DString, $res ); |
| 698 | + return new WSData( WSData::DString, $res ); |
699 | 699 | } |
700 | 700 | |
701 | 701 | protected function funcStrlen( $args, $pos ) { |
702 | 702 | $this->checkParamsCount( $args, $pos, 1 ); |
703 | | - return new ISData( ISData::DInt, mb_strlen( $args[0]->toString() ) ); |
| 703 | + return new WSData( WSData::DInt, mb_strlen( $args[0]->toString() ) ); |
704 | 704 | } |
705 | 705 | |
706 | 706 | protected function funcSubstr( $args, $pos ) { |
— | — | @@ -707,7 +707,7 @@ |
708 | 708 | $s = $args[0]->toString(); |
709 | 709 | $start = $args[1]->toInt(); |
710 | 710 | $end = $args[2]->toInt(); |
711 | | - return new ISData( ISData::DString, mb_substr( $s, $start, $end ) ); |
| 711 | + return new WSData( WSData::DString, mb_substr( $s, $start, $end ) ); |
712 | 712 | } |
713 | 713 | |
714 | 714 | protected function funcStrreplace( $args, $pos ) { |
— | — | @@ -715,50 +715,50 @@ |
716 | 716 | $s = $args[0]->toString(); |
717 | 717 | $old = $args[1]->toString(); |
718 | 718 | $new = $args[2]->toString(); |
719 | | - return new ISData( ISData::DString, str_replace( $old, $new, $s ) ); |
| 719 | + return new WSData( WSData::DString, str_replace( $old, $new, $s ) ); |
720 | 720 | } |
721 | 721 | |
722 | 722 | protected function funcSplit( $args, $pos ) { |
723 | 723 | $this->checkParamsCount( $args, $pos, 2 ); |
724 | 724 | $list = explode( $args[0]->toString(), $args[1]->toString() ); |
725 | | - return ISData::newFromPHPVar( $list ); |
| 725 | + return WSData::newFromPHPVar( $list ); |
726 | 726 | } |
727 | 727 | |
728 | 728 | protected function funcJoin( $args, $pos ) { |
729 | 729 | $this->checkParamsCount( $args, $pos, 2 ); |
730 | 730 | $seperator = $args[0]->toString(); |
731 | | - if( $args[1]->type == ISData::DList ) { |
| 731 | + if( $args[1]->type == WSData::DList ) { |
732 | 732 | $bits = $args[1]->data; |
733 | 733 | } else { |
734 | 734 | $bits = array_slice( $args, 1 ); |
735 | 735 | } |
736 | 736 | foreach( $bits as &$bit ) |
737 | 737 | $bit = $bit->toString(); |
738 | | - return new ISData( ISData::DString, implode( $seperator, $bits ) ); |
| 738 | + return new WSData( WSData::DString, implode( $seperator, $bits ) ); |
739 | 739 | } |
740 | 740 | |
741 | 741 | protected function funcCount( $args, $pos ) { |
742 | 742 | $this->checkParamsCount( $args, $pos, 1 ); |
743 | | - return new ISData( ISData::DInt, count( $args[0]->toList()->data ) ); |
| 743 | + return new WSData( WSData::DInt, count( $args[0]->toList()->data ) ); |
744 | 744 | } |
745 | 745 | |
746 | 746 | protected function castString( $args, $pos ) { |
747 | 747 | $this->checkParamsCount( $args, $pos, 1 ); |
748 | | - return ISData::castTypes( $args[0], ISData::DString ); |
| 748 | + return WSData::castTypes( $args[0], WSData::DString ); |
749 | 749 | } |
750 | 750 | |
751 | 751 | protected function castInt( $args, $pos ) { |
752 | 752 | $this->checkParamsCount( $args, $pos, 1 ); |
753 | | - return ISData::castTypes( $args[0], ISData::DInt ); |
| 753 | + return WSData::castTypes( $args[0], WSData::DInt ); |
754 | 754 | } |
755 | 755 | |
756 | 756 | protected function castFloat( $args, $pos ) { |
757 | 757 | $this->checkParamsCount( $args, $pos, 1 ); |
758 | | - return ISData::castTypes( $args[0], ISData::DFloat ); |
| 758 | + return WSData::castTypes( $args[0], WSData::DFloat ); |
759 | 759 | } |
760 | 760 | |
761 | 761 | protected function castBool( $args, $pos ) { |
762 | 762 | $this->checkParamsCount( $args, $pos, 1 ); |
763 | | - return ISData::castTypes( $args[0], ISData::DBool ); |
| 763 | + return WSData::castTypes( $args[0], WSData::DBool ); |
764 | 764 | } |
765 | 765 | } |
Index: trunk/extensions/WikiScripts/interpreter/CallStack.php |
— | — | @@ -1,39 +1,39 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -abstract class ISCallStackEntry { |
| 4 | +abstract class WSCallStackEntry { |
5 | 5 | abstract function toString(); |
6 | 6 | } |
7 | 7 | |
8 | | -abstract class ISCallStackFunctionEntry extends ISCallStackEntry { |
| 8 | +abstract class WSCallStackFunctionEntry extends WSCallStackEntry { |
9 | 9 | public $module; |
10 | 10 | public $function; |
11 | 11 | } |
12 | 12 | |
13 | | -class ISCallStackFunctionFromModuleEntry extends ISCallStackFunctionEntry { |
| 13 | +class WSCallStackFunctionFromModuleEntry extends WSCallStackFunctionEntry { |
14 | 14 | public $invokingModule; |
15 | 15 | public $line; |
16 | 16 | |
17 | 17 | public function toString() { |
18 | | - return wfMsg( 'inlinescripts-call-frommodule', $this->module, $this->function, |
| 18 | + return wfMsg( 'wikiscripts-call-frommodule', $this->module, $this->function, |
19 | 19 | $this->invokingModule, $this->line ); |
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | | -class ISCallStackFunctionFromWikitextEntry extends ISCallStackFunctionEntry { |
| 23 | +class WSCallStackFunctionFromWikitextEntry extends WSCallStackFunctionEntry { |
24 | 24 | public function toString() { |
25 | | - return wfMsg( 'inlinescripts-call-frommodule', $this->module, $this->function ); |
| 25 | + return wfMsg( 'wikiscripts-call-frommodule', $this->module, $this->function ); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | | -class ISCallStackParseEntry extends ISCallStackEntry { |
| 29 | +class WSCallStackParseEntry extends WSCallStackEntry { |
30 | 30 | public $text; |
31 | 31 | |
32 | 32 | public function toString() { |
33 | | - return wfMsg( 'inlinescripts-call-parse', $this->text ); |
| 33 | + return wfMsg( 'wikiscripts-call-parse', $this->text ); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | | -class ISCallStack { |
| 37 | +class WSCallStack { |
38 | 38 | var $mInterpreter, $mStack; |
39 | 39 | |
40 | 40 | public function __construct( $interpreter ) { |
— | — | @@ -46,14 +46,14 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function isFull() { |
50 | | - global $wgInlineScriptsMaxCallStackDepth; |
| 50 | + global $wgScriptsMaxCallStackDepth; |
51 | 51 | |
52 | | - return count( $this->mStack ) >= $wgInlineScriptsMaxCallStackDepth; |
| 52 | + return count( $this->mStack ) >= $wgScriptsMaxCallStackDepth; |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function contains( $module, $name ) { |
56 | 56 | foreach( $this->mStack as $entry ) { |
57 | | - if( $entry instanceof ISCallStackFunctionEntry ) { |
| 57 | + if( $entry instanceof WSCallStackFunctionEntry ) { |
58 | 58 | if( $entry->module == $module && $entry->function == $name ) { |
59 | 59 | return true; |
60 | 60 | } |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function addFunctionFromModule( $module, $name, $invokingModule, $line ) { |
67 | | - $entry = new ISCallStackFunctionFromModuleEntry(); |
| 67 | + $entry = new WSCallStackFunctionFromModuleEntry(); |
68 | 68 | $entry->module = $module; |
69 | 69 | $entry->function = $name; |
70 | 70 | $entry->invokingModule = $invokingModule; |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function addFunctionFromWikitext( $module, $name ) { |
76 | | - $entry = new ISCallStackFunctionFromWikitextEntry(); |
| 76 | + $entry = new WSCallStackFunctionFromWikitextEntry(); |
77 | 77 | $entry->module = $module; |
78 | 78 | $entry->function = $name; |
79 | 79 | $this->mStack[] = $entry; |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | $wikitext = substr( $wikitext, 0, 64 ) . "..."; |
85 | 85 | } |
86 | 86 | |
87 | | - $entry = new ISCallStackParseEntry(); |
| 87 | + $entry = new WSCallStackParseEntry(); |
88 | 88 | $entry->text = $wikitext; |
89 | 89 | $this->mStack[] = $entry; |
90 | 90 | } |
Index: trunk/extensions/WikiScripts/interpreter/Interpreter.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | /** |
33 | 33 | * The global interpreter object. Each parser has one. |
34 | 34 | */ |
35 | | -class ISInterpreter { |
| 35 | +class WSInterpreter { |
36 | 36 | const ParserVersion = 1; |
37 | 37 | |
38 | 38 | var $mParser, $mUseCache, $mUsedModules, $mCallStack; |
— | — | @@ -41,12 +41,12 @@ |
42 | 42 | static $mCodeParser; |
43 | 43 | |
44 | 44 | public function __construct( $parser ) { |
45 | | - global $wgInlineScriptsUseCache; |
| 45 | + global $wgScriptsUseCache; |
46 | 46 | |
47 | 47 | $this->mParser = $parser; |
48 | | - $this->mUseCache = $wgInlineScriptsUseCache; |
| 48 | + $this->mUseCache = $wgScriptsUseCache; |
49 | 49 | |
50 | | - $this->mCallStack = new ISCallStack( $this ); |
| 50 | + $this->mCallStack = new WSCallStack( $this ); |
51 | 51 | $this->mUsedModules = array(); |
52 | 52 | $this->mMaxRecursion = |
53 | 53 | $this->mEvaluations = |
— | — | @@ -54,19 +54,19 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function invokeCodeParser( $code, $module, $method = 'parse' ) { |
58 | | - global $wgInlineScriptsParserClass, $wgInlineScriptsLimits; |
| 58 | + global $wgScriptsParserClass, $wgScriptsLimits; |
59 | 59 | |
60 | 60 | if( !self::$mCodeParser ) { |
61 | | - self::$mCodeParser = new $wgInlineScriptsParserClass(); |
| 61 | + self::$mCodeParser = new $wgScriptsParserClass(); |
62 | 62 | } |
63 | 63 | |
64 | 64 | if( self::$mCodeParser->needsScanner() ) { |
65 | | - $input = new ISScanner( $module, $code ); |
| 65 | + $input = new WSScanner( $module, $code ); |
66 | 66 | } else { |
67 | 67 | $input = $code; |
68 | 68 | } |
69 | 69 | |
70 | | - return self::$mCodeParser->$method( $input, $module, $wgInlineScriptsLimits['tokens'] ); |
| 70 | + return self::$mCodeParser->$method( $input, $module, $wgScriptsLimits['tokens'] ); |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | public static function invalidateModule( $title ) { |
77 | 77 | global $parserMemc; |
78 | 78 | |
79 | | - $key = ISModule::getCacheKey( $title ); |
| 79 | + $key = WSModule::getCacheKey( $title ); |
80 | 80 | $parserMemc->delete( $key ); |
81 | 81 | } |
82 | 82 | |
— | — | @@ -108,29 +108,29 @@ |
109 | 109 | * @return Boolean |
110 | 110 | */ |
111 | 111 | public function checkRecursionLimit( $rec ) { |
112 | | - global $wgInlineScriptsLimits; |
| 112 | + global $wgScriptsLimits; |
113 | 113 | if( $rec > $this->mMaxRecursion ) |
114 | 114 | $this->mMaxRecursion = $rec; |
115 | | - return $rec <= $wgInlineScriptsLimits['depth']; |
| 115 | + return $rec <= $wgScriptsLimits['depth']; |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Increases the number of evaluations. |
120 | 120 | * |
121 | | - * @param $module ISModule Module where the evaluation happens |
| 121 | + * @param $module WSModule Module where the evaluation happens |
122 | 122 | * @param $line int Line number of the evaluation |
123 | 123 | * @return Boolean |
124 | 124 | */ |
125 | 125 | public function increaseEvaluationsCount( $module, $line ) { |
126 | | - global $wgInlineScriptsLimits; |
| 126 | + global $wgScriptsLimits; |
127 | 127 | $this->mEvaluations++; |
128 | | - if( $this->mEvaluations > $wgInlineScriptsLimits['evaluations'] ) |
129 | | - throw new ISUserVisibleException( 'toomanyevals', $module, $line ); |
| 128 | + if( $this->mEvaluations > $wgScriptsLimits['evaluations'] ) |
| 129 | + throw new WSUserVisibleException( 'toomanyevals', $module, $line ); |
130 | 130 | } |
131 | 131 | |
132 | 132 | public function getMaxTokensLeft() { |
133 | | - global $wgInlineScriptsLimits; |
134 | | - return $wgInlineScriptsLimits['tokens']; |
| 133 | + global $wgScriptsLimits; |
| 134 | + return $wgScriptsLimits['tokens']; |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | $this->addModuleTitle( $title ); |
161 | 161 | |
162 | 162 | // Try local cache |
163 | | - $key = ISModule::getCacheKey( $title ); |
| 163 | + $key = WSModule::getCacheKey( $title ); |
164 | 164 | if( $this->mUseCache && isset( $this->mParserCache[$key] ) ) { |
165 | 165 | $module = $this->mParserCache[$key]; |
166 | 166 | $this->addModuleTitle( $module->getTitle() ); |
— | — | @@ -171,7 +171,7 @@ |
172 | 172 | wfProfileIn( __METHOD__ . '-unserialize' ); |
173 | 173 | $cached = $parserMemc->get( $key ); |
174 | 174 | wfProfileOut( __METHOD__ . '-unserialize' ); |
175 | | - if( $this->mUseCache && @$cached instanceof ISModule && !$cached->isOutOfDate() ) { |
| 175 | + if( $this->mUseCache && @$cached instanceof WSModule && !$cached->isOutOfDate() ) { |
176 | 176 | $this->mParserCache[$key] = $cached; |
177 | 177 | $this->addModuleTitle( $cached->getTitle() ); |
178 | 178 | wfProfileOut( __METHOD__ ); |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | // Parse |
189 | 189 | $moduleName = $rev->getTitle()->getText(); |
190 | 190 | $out = self::invokeCodeParser( $rev->getText(), $moduleName ); |
191 | | - $module = ISModule::newFromParserOutput( $this, $rev->getTitle(), $rev->getId(), $out ); |
| 191 | + $module = WSModule::newFromParserOutput( $this, $rev->getTitle(), $rev->getId(), $out ); |
192 | 192 | |
193 | 193 | // Save to cache |
194 | 194 | $this->mParserCache[$key] = $module; |
— | — | @@ -214,50 +214,50 @@ |
215 | 215 | /** |
216 | 216 | * Invokes the user function from script code. |
217 | 217 | * |
218 | | - * @param $module ISModule/string Module or its name |
| 218 | + * @param $module WSModule/string Module or its name |
219 | 219 | * @param $name string Name of the function |
220 | | - * @param $args array(ISData) Arguments of the function |
221 | | - * @param $parentContext ISEvaluationContext The context from which the function was invoked |
| 220 | + * @param $args array(WSData) Arguments of the function |
| 221 | + * @param $parentContext WSEvaluationContext The context from which the function was invoked |
222 | 222 | * @param $line The line from which the function was invoked. |
223 | | - * @return ISData |
| 223 | + * @return WSData |
224 | 224 | */ |
225 | 225 | public function invokeUserFunctionFromModule( $module, $name, $args, $parentContext, $line ) { |
226 | | - global $wgInlineScriptsAllowRecursion, $wgInlineScriptsMaxCallStackDepth; |
| 226 | + global $wgScriptsAllowRecursion, $wgScriptsMaxCallStackDepth; |
227 | 227 | |
228 | 228 | // Load module |
229 | | - if( $module instanceof ISModule ) { |
| 229 | + if( $module instanceof WSModule ) { |
230 | 230 | $moduleName = $module->getName(); |
231 | 231 | } else { |
232 | 232 | $moduleName = $module; |
233 | 233 | |
234 | 234 | $moduleTitle = Title::makeTitleSafe( NS_MODULE, $moduleName ); |
235 | 235 | if( !$moduleTitle instanceof Title || $moduleTitle->getNamespace() != NS_MODULE ) { |
236 | | - throw new ISUserVisibleException( 'nonexistent-module', $parentContext->mModuleName, $line, array( $moduleName ) ); |
| 236 | + throw new WSUserVisibleException( 'nonexistent-module', $parentContext->mModuleName, $line, array( $moduleName ) ); |
237 | 237 | } |
238 | 238 | |
239 | 239 | $module = $this->getModule( $moduleTitle ); |
240 | 240 | if( !$module ) { |
241 | | - throw new ISUserVisibleException( 'nonexistent-module', $parentContext->mModuleName, $line, array( $moduleName ) ); |
| 241 | + throw new WSUserVisibleException( 'nonexistent-module', $parentContext->mModuleName, $line, array( $moduleName ) ); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Load the function and handle possible errors |
246 | 246 | $function = $module->getFunction( $name ); |
247 | 247 | if( !$function ) { |
248 | | - throw new ISUserVisibleException( 'unknownfunction-user', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
| 248 | + throw new WSUserVisibleException( 'unknownfunction-user', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
249 | 249 | } |
250 | 250 | if( count( $args ) < $function->getMinArgCount() ) { |
251 | | - throw new ISUserVisibleException( 'notenoughargs-user', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
| 251 | + throw new WSUserVisibleException( 'notenoughargs-user', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
252 | 252 | } |
253 | | - if( !$wgInlineScriptsAllowRecursion && $this->mCallStack->contains( $moduleName, $name ) ) { |
254 | | - throw new ISUserVisibleException( 'recursion', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
| 253 | + if( !$wgScriptsAllowRecursion && $this->mCallStack->contains( $moduleName, $name ) ) { |
| 254 | + throw new WSUserVisibleException( 'recursion', $parentContext->mModuleName, $line, array( $moduleName, $name ) ); |
255 | 255 | } |
256 | 256 | if( $this->mCallStack->isFull() ) { |
257 | | - throw new ISUserVisibleException( 'toodeeprecursion', $parentContext->mModuleName, $line, array( $wgInlineScriptsMaxCallStackDepth ) ); |
| 257 | + throw new WSUserVisibleException( 'toodeeprecursion', $parentContext->mModuleName, $line, array( $wgScriptsMaxCallStackDepth ) ); |
258 | 258 | } |
259 | 259 | |
260 | 260 | // Prepare the context and the arguments |
261 | | - $context = new ISEvaluationContext( $this, $module, $name, $parentContext->getFrame() ); |
| 261 | + $context = new WSEvaluationContext( $this, $module, $name, $parentContext->getFrame() ); |
262 | 262 | foreach( $args as $n => $arg ) { |
263 | 263 | if( isset( $function->args[$n] ) ) { |
264 | 264 | $argname = $function->args[$n]; |
— | — | @@ -286,42 +286,42 @@ |
287 | 287 | * @return string |
288 | 288 | */ |
289 | 289 | public function invokeUserFunctionFromWikitext( $moduleName, $name, $args, $frame ) { |
290 | | - global $wgInlineScriptsAllowRecursion; |
| 290 | + global $wgScriptsAllowRecursion; |
291 | 291 | |
292 | 292 | // Load module |
293 | 293 | $moduleTitle = Title::makeTitleSafe( NS_MODULE, $moduleName ); |
294 | 294 | if( !$moduleTitle instanceof Title || $moduleTitle->getNamespace() != NS_MODULE ) { |
295 | | - throw new ISTransclusionException( 'nonexistent-module', array( $moduleName ) ); |
| 295 | + throw new WSTransclusionException( 'nonexistent-module', array( $moduleName ) ); |
296 | 296 | } |
297 | 297 | |
298 | 298 | $module = $this->getModule( $moduleTitle ); |
299 | 299 | if( !$module ) { |
300 | | - throw new ISTransclusionException( 'nonexistent-module', array( $moduleName ) ); |
| 300 | + throw new WSTransclusionException( 'nonexistent-module', array( $moduleName ) ); |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Load the function and handle possible errors |
304 | 304 | $function = $module->getFunction( $name ); |
305 | 305 | if( !$function ) { |
306 | | - throw new ISTransclusionException( 'unknownfunction-user', array( $moduleName, $name ) ); |
| 306 | + throw new WSTransclusionException( 'unknownfunction-user', array( $moduleName, $name ) ); |
307 | 307 | } |
308 | 308 | if( count( $args ) < $function->getMinArgCount() ) { |
309 | | - throw new ISTransclusionException( 'notenoughargs-user', array( $moduleName, $name ) ); |
| 309 | + throw new WSTransclusionException( 'notenoughargs-user', array( $moduleName, $name ) ); |
310 | 310 | } |
311 | | - if( !$wgInlineScriptsAllowRecursion && $this->mCallStack->contains( $moduleName, $name ) ) { |
312 | | - throw new ISTransclusionException( 'recursion', array( $moduleName, $name ) ); |
| 311 | + if( !$wgScriptsAllowRecursion && $this->mCallStack->contains( $moduleName, $name ) ) { |
| 312 | + throw new WSTransclusionException( 'recursion', array( $moduleName, $name ) ); |
313 | 313 | } |
314 | 314 | if( $this->mCallStack->isFull() ) { |
315 | 315 | // Depsite seeming an unlikely place, this may actually happen if the user will try to bypass the |
316 | 316 | // stack depth limit by using parse( '{{i:module|func}}' ) |
317 | | - throw new ISTransclusionException( 'toodeeprecursion', array( $wgInlineScriptsMaxCallStackDepth ) ); |
| 317 | + throw new WSTransclusionException( 'toodeeprecursion', array( $wgScriptsMaxCallStackDepth ) ); |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Prepare the context and the arguments |
321 | | - $context = new ISEvaluationContext( $this, $module, $name, $frame ); |
| 321 | + $context = new WSEvaluationContext( $this, $module, $name, $frame ); |
322 | 322 | foreach( $args as $n => $arg ) { |
323 | 323 | if( isset( $function->args[$n] ) ) { |
324 | 324 | $argname = $function->args[$n]; |
325 | | - $context->setArgument( $argname, new ISData( ISData::DString, strval( $arg ) ) ); |
| 325 | + $context->setArgument( $argname, new WSData( WSData::DString, strval( $arg ) ) ); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
— | — | @@ -339,12 +339,12 @@ |
340 | 340 | protected function doInvokeFunction( $function, $context ) { |
341 | 341 | // Indicates whether the data from append/yield should be used |
342 | 342 | $useOutput = true; |
343 | | - $result = new ISData(); |
| 343 | + $result = new WSData(); |
344 | 344 | |
345 | 345 | try { |
346 | 346 | $context->evaluateNode( $function->body, 0 ); |
347 | | - } catch( ISException $e ) { |
348 | | - if( $e instanceof ISReturnException ) { |
| 347 | + } catch( WSException $e ) { |
| 348 | + if( $e instanceof WSReturnException ) { |
349 | 349 | $result = $e->getResult(); |
350 | 350 | $useOutput = $e->isEmpty(); |
351 | 351 | } else { |
— | — | @@ -364,7 +364,7 @@ |
365 | 365 | /** |
366 | 366 | * Represents an individual module. |
367 | 367 | */ |
368 | | -class ISModule { |
| 368 | +class WSModule { |
369 | 369 | var $mTitle, $mFunctions, $mParserVersion; |
370 | 370 | |
371 | 371 | // Revision ID |
— | — | @@ -377,7 +377,7 @@ |
378 | 378 | * Initializes module from the code parser output. |
379 | 379 | */ |
380 | 380 | public static function newFromParserOutput( $interpreter, $title, $revid, $output ) { |
381 | | - $m = new ISModule(); |
| 381 | + $m = new WSModule(); |
382 | 382 | $m->mTitle = $title; |
383 | 383 | $m->mRevID = $revid; |
384 | 384 | $m->mParserVersion = $output->getVersion(); |
— | — | @@ -391,7 +391,7 @@ |
392 | 392 | // <function> ::= function id leftbracket <arglist> rightbracket leftcurly <stmts> rightcurly (total 8) |
393 | 393 | // <function> ::= function id leftbracket rightbracket leftcurly <stmts> rightcurly (total 7) |
394 | 394 | $c = $funcnode->getChildren(); |
395 | | - $func = new ISFunction(); |
| 395 | + $func = new WSFunction(); |
396 | 396 | $func->name = $c[1]->value; |
397 | 397 | |
398 | 398 | if( $funcnode->getChildrenCount() == 8 ) { |
— | — | @@ -465,15 +465,15 @@ |
466 | 466 | * Returns whether the module should be reparsed or not. |
467 | 467 | */ |
468 | 468 | public function isOutOfDate() { |
469 | | - global $wgInlineScriptsParserClass; |
470 | | - return $wgInlineScriptsParserClass::getVersion() != $this->mParserVersion; |
| 469 | + global $wgScriptsParserClass; |
| 470 | + return $wgScriptsParserClass::getVersion() != $this->mParserVersion; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
475 | 475 | * Represents a function. |
476 | 476 | */ |
477 | | -class ISFunction { |
| 477 | +class WSFunction { |
478 | 478 | public $name; |
479 | 479 | public $args; |
480 | 480 | public $body; |
Index: trunk/extensions/WikiScripts/interpreter/LRTable.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Autogenerated SLR-table for inline scripts language. |
| 5 | + * Autogenerated SLR-table for scripts language. |
6 | 6 | * |
7 | 7 | * You should not try to modify it manually (it's very easy to break). |
8 | 8 | * Use syntax.txt and buildLRTables.php insteaed. |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | * Generated on 2011-08-13 21:53:42. |
24 | 24 | */ |
25 | 25 | |
26 | | -class ISLRTable { |
| 26 | +class WSLRTable { |
27 | 27 | |
28 | 28 | const Timestamp = '2011-08-13 21:53:42'; |
29 | 29 | |
Index: trunk/extensions/WikiScripts/interpreter/Shared.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | /** |
29 | 29 | * This class represents a terminal of the script grammar. |
30 | 30 | */ |
31 | | -class ISToken { |
| 31 | +class WSToken { |
32 | 32 | // Constant values should match ones in syntax.txt |
33 | 33 | const TEnd = '$'; |
34 | 34 | const TAppend = 'append'; |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | /** |
92 | 92 | * This class represents a non-terminal of the script grammar. |
93 | 93 | */ |
94 | | -class ISParserTreeNode { |
| 94 | +class WSParserTreeNode { |
95 | 95 | var $mType, $mChildren; |
96 | 96 | |
97 | 97 | public function __construct( $parser, $id ) { |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | public function addChild( $node ) { |
103 | 103 | // Since we do not want a long chain of "exprSomething -> exprWhatever" in the parser tree, |
104 | 104 | // we cut it out at the parsing stage |
105 | | - if( $node instanceof ISParserTreeNode ) { |
| 105 | + if( $node instanceof WSParserTreeNode ) { |
106 | 106 | $children = $node->getChildren(); |
107 | 107 | if( count( $children ) == 1 && strpos( $node->mType, "expr" ) === 0 |
108 | 108 | && strpos( @$children[0]->mType, "expr" ) === 0 ) { |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | public function formatStringArray() { |
139 | 139 | $s = array( "<nonterminal type=\"{$this->mType}\">" ); |
140 | 140 | foreach( $this->mChildren as $child ) { |
141 | | - if( $child instanceof ISParserTreeNode ) { |
| 141 | + if( $child instanceof WSParserTreeNode ) { |
142 | 142 | $sub = $child->formatStringArray(); |
143 | 143 | foreach( $sub as $str ) |
144 | 144 | $s[] = "\t" . $str; |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | /** |
155 | 155 | * Generalized script parser. |
156 | 156 | */ |
157 | | -interface ISParser { |
| 157 | +interface WSParser { |
158 | 158 | /** |
159 | 159 | * If this function returns true, code scanner is passed to parse(). |
160 | 160 | * Otherwise, code itself is passed. |
— | — | @@ -162,29 +162,29 @@ |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Parses code (in text or scanner) to parser tree. |
166 | | - * @param input ISScanner Input (scanner or string) |
| 166 | + * @param input WSScanner Input (scanner or string) |
167 | 167 | * @param maxTokens int Maximal amount of tokens |
168 | | - * @return ISParserTreeNode |
| 168 | + * @return WSParserTreeNode |
169 | 169 | */ |
170 | 170 | public function parse( $input, $module, $maxTokens ); |
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Returns an array of the syntax errors in the code |
174 | | - * @param input ISSCanner Input (scanner or string) |
| 174 | + * @param input WSSCanner Input (scanner or string) |
175 | 175 | * @param maxTokens int Maximal amount of tokens |
176 | 176 | * @return array(string) |
177 | 177 | */ |
178 | 178 | public function getSyntaxErrors( $input, $moudle, $maxTokens ); |
179 | 179 | } |
180 | 180 | |
181 | | -class ISException extends MWException {} |
| 181 | +class WSException extends MWException {} |
182 | 182 | |
183 | 183 | // Exceptions that we might conceivably want to report to ordinary users |
184 | 184 | // (i.e. exceptions that don't represent bugs in the extension itself) |
185 | | -class ISUserVisibleException extends ISException { |
| 185 | +class WSUserVisibleException extends WSException { |
186 | 186 | function __construct( $exception_id, $module, $line, $params = array() ) { |
187 | | - $codelocation = wfMsg( 'inlinescripts-codelocation', $module, $line ); |
188 | | - $msg = wfMsgExt( 'inlinescripts-exception-' . $exception_id, array(), array_merge( array( $codelocation ), $params ) ); |
| 187 | + $codelocation = wfMsg( 'wikiscripts-codelocation', $module, $line ); |
| 188 | + $msg = wfMsgExt( 'wikiscripts-exception-' . $exception_id, array(), array_merge( array( $codelocation ), $params ) ); |
189 | 189 | parent::__construct( $msg ); |
190 | 190 | |
191 | 191 | $this->mExceptionID = $exception_id; |
— | — | @@ -201,9 +201,9 @@ |
202 | 202 | /** |
203 | 203 | * Exceptions caused by the error on script transclusion error, i.e. not in script. |
204 | 204 | */ |
205 | | -class ISTransclusionException extends ISException { |
| 205 | +class WSTransclusionException extends WSException { |
206 | 206 | function __construct( $exception_id, $params = array() ) { |
207 | | - $msg = wfMsgExt( 'inlinescripts-transerror-' . $exception_id, array(), $params ); |
| 207 | + $msg = wfMsgExt( 'wikiscripts-transerror-' . $exception_id, array(), $params ); |
208 | 208 | parent::__construct( $msg ); |
209 | 209 | |
210 | 210 | $this->mExceptionID = $exception_id; |
— | — | @@ -215,12 +215,12 @@ |
216 | 216 | * Exceptions used for control structures that need to break out of deep function |
217 | 217 | * nesting level (e.g. break or continue). |
218 | 218 | */ |
219 | | -class ISControlException extends ISUserVisibleException {} |
| 219 | +class WSControlException extends WSUserVisibleException {} |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Exception that allows to return from a function. |
223 | 223 | */ |
224 | | -class ISReturnException extends ISControlException { |
| 224 | +class WSReturnException extends WSControlException { |
225 | 225 | function __construct( $result, $empty ) { |
226 | 226 | $this->mResult = $result; |
227 | 227 | $this->mEmpty = $empty; |
— | — | @@ -238,14 +238,14 @@ |
239 | 239 | /** |
240 | 240 | * Code parser output. |
241 | 241 | */ |
242 | | -class ISParserOutput { |
| 242 | +class WSParserOutput { |
243 | 243 | var $mTree, $mTokensCount, $mVersion; |
244 | 244 | |
245 | 245 | public function __construct( $tree, $tokens ) { |
246 | | - global $wgInlineScriptsParserClass; |
| 246 | + global $wgScriptsParserClass; |
247 | 247 | $this->mTree = $tree; |
248 | 248 | $this->mTokensCount = $tokens; |
249 | | - $this->mVersion = $wgInlineScriptsParserClass::getVersion(); |
| 249 | + $this->mVersion = $wgScriptsParserClass::getVersion(); |
250 | 250 | } |
251 | 251 | |
252 | 252 | public function getParserTree() { |
— | — | @@ -257,5 +257,5 @@ |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | | -// Used by ISEvaluationContext::setVar |
262 | | -class ISPlaceholder {} |
| 261 | +// Used by WSEvaluationContext::setVar |
| 262 | +class WSPlaceholder {} |
Index: trunk/extensions/WikiScripts/interpreter/buildLRTables.php |
— | — | @@ -350,7 +350,7 @@ |
351 | 351 | $s = <<<END |
352 | 352 | <html> |
353 | 353 | <head> |
354 | | -<title>Inline scripts LR table dump</title> |
| 354 | +<title>Scripts LR table dump</title> |
355 | 355 | <style type="text/css"> |
356 | 356 | table { |
357 | 357 | margin: 1em 1em 1em 0; |
— | — | @@ -468,7 +468,7 @@ |
469 | 469 | <?php |
470 | 470 | |
471 | 471 | /** |
472 | | - * Autogenerated SLR-table for inline scripts language. |
| 472 | + * Autogenerated SLR-table for scripts language. |
473 | 473 | * |
474 | 474 | * You should not try to modify it manually (it's very easy to break). |
475 | 475 | * Use syntax.txt and buildLRTables.php insteaed. |
— | — | @@ -489,7 +489,7 @@ |
490 | 490 | * Generated on {$date}. |
491 | 491 | */ |
492 | 492 | |
493 | | -class ISLRTable { |
| 493 | +class WSLRTable { |
494 | 494 | |
495 | 495 | const Timestamp = '{$date}'; |
496 | 496 | |
— | — | @@ -545,7 +545,7 @@ |
546 | 546 | * version in separate file. |
547 | 547 | */ |
548 | 548 | |
549 | | -define( 'IS_LR_VERSION', "{$ts}" ); |
| 549 | +define( 'WS_LR_VERSION', "{$ts}" ); |
550 | 550 | |
551 | 551 | EOF; |
552 | 552 | } |
Index: trunk/extensions/WikiScripts/Hooks.php |
— | — | @@ -21,18 +21,18 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | /** |
25 | | - * Hooks for InlineScripts extension. |
| 25 | + * Hooks for WikiScripts extension. |
26 | 26 | */ |
27 | | -class ISHooks { |
| 27 | +class WSHooks { |
28 | 28 | /** |
29 | 29 | * Returns the interpreter for a given parser. |
30 | 30 | * |
31 | 31 | * @static |
32 | | - * @return InlineScriptInterpreter |
| 32 | + * @return WSIntepreter |
33 | 33 | */ |
34 | 34 | public static function getInterpreter( $parser ) { |
35 | 35 | if( !isset( $parser->is_interpreter ) || !$parser->is_interpreter ) { |
36 | | - $parser->is_interpreter = new ISInterpreter( $parser ); |
| 36 | + $parser->is_interpreter = new WSInterpreter( $parser ); |
37 | 37 | } |
38 | 38 | return $parser->is_interpreter; |
39 | 39 | } |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | * @param $parser Parser |
44 | 44 | */ |
45 | 45 | public static function setupParserHook( &$parser ) { |
46 | | - $parser->setFunctionHook( 'i', 'ISHooks::callHook', SFH_NO_HASH | SFH_OBJECT_ARGS ); |
| 46 | + $parser->setFunctionHook( 'i', 'WSHooks::callHook', SFH_NO_HASH | SFH_OBJECT_ARGS ); |
47 | 47 | return true; |
48 | 48 | } |
49 | 49 | |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | |
83 | 83 | try { |
84 | 84 | if( count( $args ) < 2 ) { |
85 | | - throw new ISTransclusionException( 'nofunction' ); |
| 85 | + throw new WSTransclusionException( 'nofunction' ); |
86 | 86 | } |
87 | 87 | |
88 | 88 | $moduleName = $parser->mStripState->unstripBoth( array_shift( $args ) ); |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | } |
93 | 93 | |
94 | 94 | $result = $i->invokeUserFunctionFromWikitext( $moduleName, $funcName, $args, $frame ); |
95 | | - } catch( ISException $e ) { |
| 95 | + } catch( WSException $e ) { |
96 | 96 | $msg = $e->getMessage(); |
97 | 97 | wfProfileOut( __METHOD__ ); |
98 | 98 | return "<strong class=\"error\">{$msg}</strong>"; |
— | — | @@ -112,10 +112,10 @@ |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | 115 | public static function handleScriptView( $text, $title, $output ) { |
116 | | - global $wgInlineScriptsUseGeSHi; |
| 116 | + global $wgScriptsUseGeSHi; |
117 | 117 | |
118 | 118 | if( $title->getNamespace() == NS_MODULE ) { |
119 | | - if( $wgInlineScriptsUseGeSHi ) { |
| 119 | + if( $wgScriptsUseGeSHi ) { |
120 | 120 | $geshi = SyntaxHighlight_GeSHi::prepare( $text, 'wikiscript' ); |
121 | 121 | $geshi->set_language_path( dirname( __FILE__ ) . '/geshi' ); |
122 | 122 | $geshi->set_language( 'wikiscript' ); |
— | — | @@ -159,11 +159,11 @@ |
160 | 160 | * @return bool |
161 | 161 | */ |
162 | 162 | public static function reportLimits( $parser, &$report ) { |
163 | | - global $wgInlineScriptsLimits; |
| 163 | + global $wgScriptsLimits; |
164 | 164 | $i = self::getInterpreter( $parser ); |
165 | 165 | $report .= |
166 | | - "Inline scripts parser evaluations: {$i->mEvaluations}/{$wgInlineScriptsLimits['evaluations']}\n" . |
167 | | - "Inline scripts AST maximal depth: {$i->mMaxRecursion}/{$wgInlineScriptsLimits['depth']}\n"; |
| 166 | + "Scripts parser evaluations: {$i->mEvaluations}/{$wgScriptsLimits['evaluations']}\n" . |
| 167 | + "Scripts AST maximal depth: {$i->mMaxRecursion}/{$wgScriptsLimits['depth']}\n"; |
168 | 168 | return true; |
169 | 169 | } |
170 | 170 | |
— | — | @@ -181,12 +181,12 @@ |
182 | 182 | $title = $editor->mTitle; |
183 | 183 | |
184 | 184 | if( $title->getNamespace() == NS_MODULE ) { |
185 | | - $errors = ISInterpreter::getSyntaxErrors( $title->getText(), $text ); |
| 185 | + $errors = WSInterpreter::getSyntaxErrors( $title->getText(), $text ); |
186 | 186 | if( !$errors ) { |
187 | 187 | return true; |
188 | 188 | } |
189 | 189 | |
190 | | - $errmsg = wfMsgExt( 'inlinescripts-error', array( 'parsemag' ), array( count( $errors ) ) ); |
| 190 | + $errmsg = wfMsgExt( 'wikiscripts-error', array( 'parsemag' ), array( count( $errors ) ) ); |
191 | 191 | $errlines = '* ' . implode( "\n* ", array_map( 'wfEscapeWikiText', $errors ) ); |
192 | 192 | $error = <<<HTML |
193 | 193 | <div class="errorbox"> |
Index: trunk/extensions/WikiScripts/LinksUpdate.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | * Class that contains hooks related to tracking links to scripts and invalidating |
31 | 31 | * pages on script change. |
32 | 32 | */ |
33 | | -class ISLinksUpdateHooks { |
| 33 | +class WSLinksUpdateHooks { |
34 | 34 | /** |
35 | 35 | * Appends script links to the output. |
36 | 36 | */ |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | $new = array(); |
53 | 53 | } |
54 | 54 | |
55 | | - $isupdate = new ISLinksUpdate( $update, $new ); |
| 55 | + $isupdate = new WSLinksUpdate( $update, $new ); |
56 | 56 | $isupdate->run(); |
57 | 57 | return true; |
58 | 58 | } |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | |
66 | 66 | if( $article->mTitle->getNamespace() == NS_MODULE ) { |
67 | 67 | // Invalidate the script cache |
68 | | - ISInterpreter::invalidateModule( $article->mTitle ); |
| 68 | + WSInterpreter::invalidateModule( $article->mTitle ); |
69 | 69 | |
70 | 70 | // Invalidate caches of articles which include the script |
71 | 71 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $article->mTitle, 'scriptlinks' ); |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | * A class that updates links on scripts like phase3/includes/LinksUpdate.php does that |
107 | 107 | * with templates. |
108 | 108 | */ |
109 | | -class ISLinksUpdate { |
| 109 | +class WSLinksUpdate { |
110 | 110 | var $mUpdate, $mId, $mNew; |
111 | 111 | |
112 | 112 | public function __construct( $update, $new ) { |