~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to scripting/php/editing/src/org/netbeans/modules/languages/php/resources/purePHP4.nbs

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
2
#
 
3
# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
4
#
 
5
# The contents of this file are subject to the terms of either the GNU
 
6
# General Public License Version 2 only ("GPL") or the Common
 
7
# Development and Distribution License("CDDL") (collectively, the
 
8
# "License"). You may not use this file except in compliance with the
 
9
# License. You can obtain a copy of the License at
 
10
# http://www.netbeans.org/cddl-gplv2.html
 
11
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 
12
# specific language governing permissions and limitations under the
 
13
# License.  When distributing the software, include this License Header
 
14
# Notice in each file and include the License file at
 
15
# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 
16
# particular file as subject to the "Classpath" exception as provided
 
17
# by Sun in the GPL Version 2 section of the License file that
 
18
# accompanied this code. If applicable, add the following below the
 
19
# License Header, with the fields enclosed by brackets [] replaced by
 
20
# your own identifying information:
 
21
# "Portions Copyrighted [year] [name of copyright owner]"
 
22
#
 
23
# Contributor(s):
 
24
#
 
25
# The Original Software is NetBeans. The Initial Developer of the Original
 
26
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
 
27
# Microsystems, Inc. All Rights Reserved.
 
28
#
 
29
# If you wish your version of this file to be governed by only the CDDL
 
30
# or only the GPL Version 2, indicate your decision by adding
 
31
# "[Contributor] elects to include this software in this distribution
 
32
# under the [CDDL or GPL Version 2] license." If you do not indicate a
 
33
# single choice of license, a recipient has the option to distribute
 
34
# your version of this file under either the CDDL, the GPL Version 2 or
 
35
# to extend the choice of license to its licensees as provided above.
 
36
# However, if you add GPL Version 2 code and therefore, elected the GPL
 
37
# Version 2 license, then the option applies only if the new code is
 
38
# made subject to such option by the copyright holder.
 
39
 
 
40
 
 
41
 
 
42
########### tokens #############################################################
 
43
 
 
44
AST {
 
45
    process:org.netbeans.modules.languages.html.HTML.process;
 
46
}
 
47
 
 
48
 
 
49
TOKEN:php_comment:( "/*" - "*/" )
 
50
TOKEN:php_line_comment:( ("#"|"//") [^ "\n" "\r"]* )
 
51
TOKEN:php_keyword:(
 
52
    "__CLASS__" |
 
53
    "__FILE__" |
 
54
    "__FUNCTION__" |
 
55
    "__LINE__" |
 
56
    "__METHOD__" |
 
57
    "abstract" |
 
58
    "and" |
 
59
    "array" |
 
60
    "as" |
 
61
    "break" |
 
62
    "case" |
 
63
    "catch" |
 
64
    "cfunction" |
 
65
    "class" |
 
66
    "clone" |
 
67
    "const" |
 
68
    "continue" |
 
69
    "declare" |
 
70
    "default" |
 
71
    "do" |
 
72
    "echo" |
 
73
    "else" |
 
74
    "elseif" |
 
75
    "enddeclare" |
 
76
    "endfor" |
 
77
    "endforeach" |
 
78
    "endif" |
 
79
    "endswitch" |
 
80
    "endwhile" |
 
81
    "exception" |
 
82
    "extends" |
 
83
    "final" |
 
84
    "for" |
 
85
    "foreach" |
 
86
    "function" |
 
87
    "global" |
 
88
    "if" |
 
89
    "implements" |
 
90
    "interface" |
 
91
    "list" |
 
92
    "new" |
 
93
    "old_function" |
 
94
    "or" |
 
95
    "php_user_filter" |
 
96
    "print" |
 
97
    "private" |
 
98
    "protected" |
 
99
    "public" |
 
100
    "return" |
 
101
    "static" |
 
102
    "switch" |
 
103
    "throw" |
 
104
    "try" |
 
105
    "use" |
 
106
    "while" |
 
107
    "xor"
 
108
)
 
109
 
 
110
TOKEN:php_builtin_function: (
 
111
    "define" |
 
112
    "defined" |
 
113
    "die" |
 
114
    "empty" |
 
115
    "eval" |
 
116
    "exit" |
 
117
    "isset" |
 
118
    "unset"
 
119
)
 
120
 
 
121
TOKEN:php_include_keyword: (
 
122
    "include" |
 
123
    "include_once" |
 
124
    "require" |
 
125
    "require_once"
 
126
)
 
127
 
 
128
TOKEN:php_type_cast: (
 
129
    ( "(" [" " "\t"]* "array" [" " "\t"]* ")" ) |
 
130
    ( "(" [" " "\t"]* "bool" [" " "\t"]* ")" ) |
 
131
    ( "(" [" " "\t"]* "boolean" [" " "\t"]* ")" ) |
 
132
    ( "(" [" " "\t"]* "float" [" " "\t"]* ")" ) |
 
133
    ( "(" [" " "\t"]* "int" [" " "\t"]* ")" ) |
 
134
    ( "(" [" " "\t"]* "integer" [" " "\t"]* ")" ) |
 
135
    ( "(" [" " "\t"]* "real" [" " "\t"]* ")" ) |
 
136
    ( "(" [" " "\t"]* "object" [" " "\t"]* ")" ) |
 
137
    ( "(" [" " "\t"]* "string" [" " "\t"]* ")" )
 
138
)
 
139
 
 
140
TOKEN:php_operator: (
 
141
    "=" | "+=" | "-=" | "*=" | "/=" | ".=" | "%=" | "&=" | "|=" | "^=" | "~=" | "<<=" | ">>=" |
 
142
    "==" | "!=" | "===" | "!==" | "<>" | ">" | "<" | ">=" | "<=" | 
 
143
    "<<" | ">>" | "++" | "--" |
 
144
    "&&" | "||" | "->" | "=>" | "::" |
 
145
    "?" | ":" | "*" | "/" | "-" | "+" | "." | "," |
 
146
    "(" | ")" | "[" | "]" | "!" | "@" | "%" | "^" | "&" |
 
147
    "~" | "|" | "\\"
 
148
)
 
149
 
 
150
TOKEN:php_separator: ( [";" "{" "}"] )
 
151
 
 
152
TOKEN:php_string:( "\"" [^ "\"" "\n" "\r"]* "\"" )
 
153
TOKEN:php_string: ( "\'" [^ "\'" "\n" "\r"]* "\'" )
 
154
TOKEN:php_string: ("`" [^ "`" "\n" "\r"]* "`" )
 
155
TOKEN:php_number:( ["0" - "9"] ["0" - "9" "."]* )
 
156
TOKEN:php_integer:( ["0" - "9"] ["0" - "9"]* )
 
157
TOKEN:php_whitespace:( [" " "\t" "\n" "\r"]+ )
 
158
TOKEN:php_variable:( 
 
159
    "$" ["a"-"z" "A"-"Z" "_"] 
 
160
    ["a"-"z" "A"-"Z" "0"-"9" "_"]*
 
161
)
 
162
TOKEN:php_identifier:( 
 
163
    ["a"-"z" "A"-"Z" "_"] 
 
164
    ["a"-"z" "A"-"Z" "0"-"9" "_"]*
 
165
)
 
166
 
 
167
TOKEN:php_delimiter: ( "?>" | "%>" ):<DEFAULT>
 
168
 
 
169
########### grammar ############################################################
 
170
 
 
171
SKIP:php_whitespace
 
172
SKIP:php_comment
 
173
SKIP:php_line_comment
 
174
 
 
175
S = ( SourceElement ) +;
 
176
 
 
177
SourceElement = Statement;
 
178
 
 
179
Statement = Block | BreakStatement | ClassDefinition | ContinueStatement | DoStatement |
 
180
    EchoStatement | EmptyStatement | ExpressionStatement | ForEachStatement | ForStatement |
 
181
    FunctionDefinition | GlobalStatement | IfStatement | InterfaceDefinition |
 
182
    ReturnStatement | SwitchStatement | StaticStatement | WhileStatement;
 
183
 
 
184
Block = "{" StatementList "}";
 
185
StatementList = ( Statement )*;
 
186
 
 
187
BreakStatement = "break" [ <php_integer> ] ";";
 
188
 
 
189
ContinueStatement = "continue" [ <php_integer> ] ";";
 
190
 
 
191
DoStatement = "do" Statement WhileCommon ";";
 
192
 
 
193
EchoStatement = ("echo" | "print") EchoArguments ";";
 
194
EchoArguments = ( "(" [ Expression ] ")" ) | [ Expression ( "," Expression )* ];
 
195
 
 
196
EmptyStatement = ";";
 
197
 
 
198
ExpressionStatement = Expression ";";
 
199
 
 
200
ForEachStatement = ForeachCommon ( ForeachStatementCurly | ForeachStatementColon );
 
201
ForeachStatementCurly = Statement;
 
202
ForeachStatementColon = ":" StatementList "endforeach" ";";
 
203
ForeachCommon = "foreach" "(" Expression "as" <php_variable> [ "=>" <php_variable> ] ")";
 
204
 
 
205
ForStatement = ForCommon ( ForStatementCurly | ForStatementColon );
 
206
ForCommon = "for" "(" Expression ";" Expression ";" Expression ")";
 
207
ForStatementCurly =  Statement;
 
208
ForStatementColon = ":" StatementList "endfor" ";";
 
209
 
 
210
GlobalStatement = "global" <php_variable> ( "," <php_variable> )* ";";
 
211
 
 
212
IfStatement = IfCommon ( IfStatementCurly | IfStatementColon );
 
213
IfCommon = "if" "(" Expression ")";
 
214
IfStatementCurly = Statement ( "elsif" "(" Expression ")" Statement )* [ "else" Statement ];
 
215
IfStatementColon = ":" StatementList
 
216
    ( "elsif" "(" Expression ")" ":" StatementList )* [ "else" ":" StatementList ] "endif" ";";
 
217
 
 
218
ReturnStatement = "return" [ Expression ] ";";
 
219
 
 
220
SwitchStatement = SwitchCommon ( SwitchStatementCurly | SwitchStatementColon );
 
221
SwitchCommon = "switch" "(" Expression ")";
 
222
SwitchStatementCurly = "{" ( CaseClause )* [ DefaultClause ] ( CaseClause )* "}";
 
223
CaseClause = "case" Expression ":" StatementList;
 
224
DefaultClause = "default" ":" StatementList;
 
225
SwitchStatementColon = ":" ( CaseClause )* [ DefaultClause ] ( CaseClause )* "endswitch" ";";
 
226
 
 
227
StaticStatement = "static" StaticVariable "=" Expression ";";
 
228
StaticVariable = <php_variable>;
 
229
 
 
230
WhileStatement = WhileCommon ( WhileStatementCurly | WhileStatementColon );
 
231
WhileCommon = "while" "(" Expression ")";
 
232
WhileStatementCurly = Statement;
 
233
WhileStatementColon = ":" StatementList "endwhile" ";";
 
234
 
 
235
Expression = LogicalORExpression | DefineExpression;
 
236
LogicalORExpression = LogicalXORExpression ( "or" LogicalXORExpression )*;
 
237
LogicalXORExpression = LogicalANDExpression ( "xor" LogicalANDExpression )*;
 
238
LogicalANDExpression = AssignmentExpression ( "and" AssignmentExpression )*;
 
239
AssignmentExpression = ConditionalExpression ( AssignmentOperator ConditionalExpression )*;
 
240
AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | ".=" | "%=" | "&=" | "|=" | "^=" | "~=" | "<<=" | ">>=";
 
241
ConditionalExpression = LogicalORORExpression [ "?" LogicalORORExpression ":" LogicalORORExpression ];
 
242
LogicalORORExpression = LogicalANDANDExpression ( "||" LogicalANDANDExpression )*;
 
243
LogicalANDANDExpression = BitwiseORExpression ( "&&" BitwiseORExpression )*;
 
244
BitwiseORExpression = BitwiseXORExpression ( "|" BitwiseXORExpression )*;
 
245
BitwiseXORExpression = BitwiseANDExpression ( "^" BitwiseANDExpression )*;
 
246
BitwiseANDExpression = EqualityExpression ( "&" EqualityExpression )*;
 
247
EqualityExpression = RelationalExpression [ EqualityOperator RelationalExpression ];
 
248
EqualityOperator = "==" | "!=" | "<>" | "===" | "!==";
 
249
RelationalExpression = BitShiftExpression [ RelationalOperator BitShiftExpression ];
 
250
RelationalOperator = "<" | "<=" | ">" | ">=";
 
251
BitShiftExpression = AdditiveExpression ( BitShiftOperator AdditiveExpression )*;
 
252
BitShiftOperator = "<<" | ">>";
 
253
AdditiveExpression = MultiplicativeExpression ( AdditiveOperator MultiplicativeExpression )*;
 
254
AdditiveOperator = "+" | "-" | ".";
 
255
MultiplicativeExpression = PostfixExpression ( MultiplicativeOperator PostfixExpression )*;
 
256
MultiplicativeOperator = "*" | "/" | "%";
 
257
PostfixExpression = UnaryExpression [ "++" | "--" ];
 
258
UnaryExpression = LeftHandSideExpression | ( UnaryOperator UnaryExpression );
 
259
UnaryOperator = "!" | "~" | "-" | "++" | "--" | "@" | <php_type_cast>;
 
260
LeftHandSideExpression = CallExpression | NewExpression | BuiltInCallExpression |
 
261
        IncludeExpression | ArrayExpression;
 
262
CallExpression = PrimaryExpression ( MemberOperator | Arguments )*;
 
263
DefineExpression = "define" "(" ConstantName "," Expression [ "," Expression ] ")";
 
264
ConstantName = <php_string>;
 
265
 
 
266
ArrayExpression = "array" "(" [ ArrayElement ( "," ArrayElement )* ] ")";
 
267
ArrayElement = AssociativeArrayElement | Expression;
 
268
AssociativeArrayElement = ArrayId "=>" Expression;
 
269
ArrayId = <php_integer> | <php_string>;
 
270
 
 
271
BuiltInCallExpression = <php_builtin_function> Arguments;
 
272
 
 
273
IncludeExpression = <php_include_keyword> IncludeArgument;
 
274
IncludeArgument = Expression;
 
275
 
 
276
NewExpression = [ "&" ] "new" <php_identifier> Arguments;
 
277
MemberOperator = "[" [ Expression ] "]" | ClassMemberOperator;
 
278
ClassMemberOperator = "->" <php_identifier>;
 
279
Arguments = "(" [ Expression ( "," Expression )* ] ")";
 
280
PrimaryExpression = ConstantExpression | ClassStaticPrimaryExpression | <php_variable> |
 
281
    "(" Expression ")";
 
282
ConstantExpression = <php_number> | <php_string> | "null" | "true" | "false";
 
283
ClassStaticPrimaryExpression = <php_identifier> [ "::" ( <php_identifier> | <php_variable> )];
 
284
 
 
285
FunctionDefinition = FunctionDeclarartion FunctionBody;
 
286
FunctionDeclarartion = "function" [ "&" ] FunctionName "(" FormalParameterList ")";
 
287
FunctionName = <php_identifier>;
 
288
FormalParameterList = [ FormalParameter ( "," FormalParameter )*];
 
289
FormalParameter = [ "&" ] <php_variable> [ "=" ConstantExpression ];
 
290
FunctionBody = Block;
 
291
 
 
292
InterfaceDefinition = "interface" ClassName [ "extends"  <php_identifier> ( "," <php_identifier> )* ] InterfaceBody;
 
293
InterfaceBody = "{" [ InterfaceStatementList ] "}";
 
294
InterfaceStatementList = InterfaceStatement ";" (InterfaceStatement ";")*;
 
295
InterfaceStatement = FunctionDeclarartion | ClassConstDeclaration;
 
296
ClassConstDeclaration = "const" <php_identifier> "=" ConstantExpression;
 
297
 
 
298
ClassDefinition = [ "abstract" ] "class" ClassName [ "extends"  <php_identifier> ]
 
299
    [ "implements" <php_identifier> ( "," <php_identifier> )* ] ClassBody;
 
300
ClassName = <php_identifier>;
 
301
ClassBody = "{" ( ClassStatement )* "}";
 
302
ClassStatement = (( ClassVarDeclaration | ClassConstDeclaration | AbstractFunctionDeclarartion) ";" ) |
 
303
    ClassDefinition | FunctionDefinition | InterfaceDefinition;
 
304
ClassVarDeclaration = ( "var" | "public" | "protected" | "private" ) <php_variable> [ "=" ConstantExpression];
 
305
AbstractFunctionDeclarartion = "abstract" FunctionDeclarartion;
 
306
 
 
307
########## Errors ##############################################################
 
308
 
 
309
MARK:ERROR: {
 
310
    type:"Error";
 
311
    message:"LBL_SYNTAX_ERROR";
 
312
}
 
313
 
 
314
MARK:error: {
 
315
    type:"Error";
 
316
    message:"LBL_UNEXPECTED_CHARACTER";
 
317
}
 
318
 
 
319
BUNDLE "org.netbeans.modules.languages.php.resources.Bundle"
 
320
 
 
321
########### code folding #######################################################
 
322
 
 
323
FOLD:ClassBody: {
 
324
    expand_type_action_name:"Expand Classes";
 
325
    collapse_type_action_name:"Collapse Classes";
 
326
}
 
327
FOLD:FunctionBody: {
 
328
    expand_type_action_name:"Expand Methods";
 
329
    collapse_type_action_name:"Collapse Methods";
 
330
}
 
331
FOLD:InterfaceBody: {
 
332
    expand_type_action_name:"Expand Classes";
 
333
    collapse_type_action_name:"Collapse Classes";
 
334
}
 
335
FOLD:php_comment: {
 
336
    expand_type_action_name:"Expand Comments";
 
337
    collapse_type_action_name:"Collapse Comments";
 
338
}
 
339
FOLD:php_line_comment: {
 
340
    expand_type_action_name:"Expand Comments";
 
341
    collapse_type_action_name:"Collapse Comments";
 
342
}
 
343
 
 
344
########### navigator ##########################################################
 
345
 
 
346
NAVIGATOR:FunctionDeclarartion: {
 
347
    display_name: org.netbeans.modules.languages.php.Php.functionName;
 
348
    icon: "org/netbeans/modules/languages/resources/method.gif";
 
349
    isLeaf: "true";
 
350
}
 
351
 
 
352
# NAVIGATOR:VariableDeclaration: {
 
353
#    display_name: "$php_identifier$";
 
354
#    tooltip: "$js_identifier$ $Initializer$";
 
355
#    icon: "/org/netbeans/modules/languages/resources/variable.gif";
 
356
#}
 
357
 
 
358
NAVIGATOR:ClassDefinition: {
 
359
    display_name: org.netbeans.modules.languages.php.Php.className;
 
360
    icon: "org/netbeans/modules/languages/resources/class.gif";
 
361
    isLeaf: "false";
 
362
}
 
363
 
 
364
NAVIGATOR:DefineExpression: {
 
365
    display_name: org.netbeans.modules.languages.php.Php.constantName;
 
366
    icon: "org/netbeans/modules/languages/php/resources/constant.gif";
 
367
    isLeaf: "true";
 
368
 
 
369
}
 
370
 
 
371
NAVIGATOR:InterfaceDefinition: {
 
372
    display_name: org.netbeans.modules.languages.php.PhpView.className;
 
373
    icon: "org/netbeans/modules/languages/resources/class.gif";
 
374
    isLeaf: "false";
 
375
}
 
376
########### colors #############################################################
 
377
 
 
378
COLOR:end_element: {
 
379
    color_name: "element";
 
380
    default_coloring: "keyword";
 
381
}
 
382
COLOR:element_end: {
 
383
    color_name: "element";
 
384
    default_coloring: "keyword";
 
385
}
 
386
    
 
387
COLOR:attribute_value: {
 
388
    default_coloring: "string";
 
389
}
 
390
COLOR:line_comment: {
 
391
    default_coloring: "comment";
 
392
}
 
393
COLOR:php_variable: {
 
394
    foreground_color: "0x098618";
 
395
}
 
396
COLOR:ClassMemberOperator: {
 
397
    color_name: "php_variable";
 
398
    foreground_color: "0x0dc223";
 
399
}
 
400
 
 
401
COLOR:php_separator: {
 
402
    color_name: "php_operator";
 
403
}
 
404
 
 
405
COLOR:php_builtin_function: {
 
406
    default_coloring: "keyword";
 
407
}
 
408
 
 
409
COLOR:php_include_keyword: {
 
410
    default_coloring: "keyword";
 
411
}
 
412
 
 
413
COLOR:php_type_cast: {
 
414
    default_coloring: "keyword";
 
415
}
 
416
 
 
417
COMPLETE "(:)"
 
418
COMPLETE "{:}"
 
419
COMPLETE "\":\""
 
420
COMPLETE "':'"
 
421
COMPLETE "[:]"
 
422
 
 
423
INDENT "(:)"
 
424
INDENT "{:}"
 
425
INDENT "[:]"
 
426
INDENT "\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\\))[^{;]*)"
 
427
 
 
428
#STORE:php_identifier: {
 
429
#    context:"Folder";
 
430
#    name:"$PropertyName$";
 
431
#}
 
432