|
1 /* |
|
2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 using System; |
|
19 using SymBuildParsingLib.Tree; |
|
20 using SymBuildParsingLib.Parser.Framework.Workers; |
|
21 using SymBuildParsingLib.Parser.Framework.Nodes; |
|
22 using SymbianTree; |
|
23 |
|
24 namespace SymBuildParsingLib.Parser.Framework.Workers |
|
25 { |
|
26 // NB: Used only for 'if', 'ifdef', 'ifndef' expressions. |
|
27 public class SymParserWorkerConditionalExpression : SymParserWorker |
|
28 { |
|
29 #region Constructors & destructor |
|
30 public SymParserWorkerConditionalExpression( SymParserWorkerContext aContext ) |
|
31 : base( aContext ) |
|
32 { |
|
33 SymNode node = new SymNodeConditionalExpression( aContext.CurrentToken ); |
|
34 aContext.Document.CurrentNode.Add( node ); |
|
35 |
|
36 // Make this child node the new parent |
|
37 aContext.Document.CurrentNode = node; |
|
38 } |
|
39 #endregion |
|
40 |
|
41 #region From SymParserWorker |
|
42 public override void RemoveChild( SymParserWorker aWorker ) |
|
43 { |
|
44 base.RemoveChild( aWorker ); |
|
45 RemoveSelf(); |
|
46 } |
|
47 #endregion |
|
48 |
|
49 #region Utility functions |
|
50 public static SymNodeConditionalExpression FindMostRecentConditionalExpression( SymNode aCurrentNode ) |
|
51 { |
|
52 SymNodeConditionalExpression ret = null; |
|
53 // |
|
54 SymNodeEnumeratorUpTreeSiblingsFirst iterator = new SymNodeEnumeratorUpTreeSiblingsFirst( aCurrentNode ); |
|
55 // |
|
56 foreach( SymNode node in iterator ) |
|
57 { |
|
58 if ( node is SymNodeConditionalExpression ) |
|
59 { |
|
60 ret = (SymNodeConditionalExpression) node; |
|
61 break; |
|
62 } |
|
63 } |
|
64 // |
|
65 return ret; |
|
66 } |
|
67 #endregion |
|
68 } |
|
69 } |