1.1 --- a/epoc32/include/cbnfparser.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,557 +0,0 @@
1.4 -// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -// All rights reserved.
1.6 -// This component and the accompanying materials are made available
1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -//
1.11 -// Initial Contributors:
1.12 -// Nokia Corporation - initial contribution.
1.13 -//
1.14 -// Contributors:
1.15 -//
1.16 -// Description:
1.17 -// This class provides a mechanism to use a BNF tree to parse an input stream.
1.18 -// The notation of the EBNF is based upon that described in the XML1.0 specification.
1.19 -// The BNF tree form used is a variation on Extended BNF and has the following rule types,
1.20 -// where the input stream must:
1.21 -// , Exact - match exactly with the provided string.
1.22 -// , Range - next character must be in the specified range.
1.23 -// , Select - next character must exist in the selected string.
1.24 -// If the select string starts with ^ it is a NOT Select.
1.25 -// , And - match all of the given sub rules
1.26 -// , Or - match one of the given sub rules
1.27 -// , NMore - match N or more times the the SINGLE subrule.
1.28 -// , Optional - match 0/1 times to the SINGLE subrule.
1.29 -// , Without - match the first subrule but NOT the second.
1.30 -// , Reference - match the referred to rule.
1.31 -// The iterative parser not only validates an input stream against the
1.32 -// BNF grammer but allows pre/post actions to be performed during the parsing.
1.33 -// Partial parsing is also allowed in that the input stream does not have to
1.34 -// completed before parsing can begin. As soon as data is added the parser
1.35 -// attempts to parse it.
1.36 -// Numerous methods are provided to assist in the building of the BNF Tree this parser uses.
1.37 -// To use this class:
1.38 -// Create a derivation and implement the virtual method TreeL() to creat a BNF rule tree
1.39 -// (the assistance methods NewBNF/NewRule etc should be used) - see DTDModel
1.40 -// To use your new parser invoke Reset and pass input data using the ProcessData method.
1.41 -//
1.42 -//
1.43 -
1.44 -#ifndef __CBNFPARSER_H__
1.45 -#define __CBNFPARSER_H__
1.46 -
1.47 -#include <e32std.h>
1.48 -#include <mdataproviderobserver.h>
1.49 -#include <cstack.h>
1.50 -#include <cfragmentedstring.h>
1.51 -#include <cbnfnode.h>
1.52 -
1.53 -//
1.54 -// forward class declarations
1.55 -//
1.56 -class CAttributeLookupTable;
1.57 -
1.58 -
1.59 -// Rule Tree node type definitions
1.60 -/** Defines types of node in a BNF tree (CBNFParser).
1.61 -
1.62 -Except for ERoot, EIncomplete, EReference, and ELastParserNodeType, the
1.63 -types define different types of rule that the input stream must meet to
1.64 -satisfy the grammar. */
1.65 -enum TParserNodeTypes
1.66 - {
1.67 - /** Root node. */
1.68 - ERoot,
1.69 - /** Incomplete node. */
1.70 - EIncomplete,
1.71 - /** Exact rule: match exactly with the provided string. */
1.72 - EExact,
1.73 - /** Range rule: next character must be in the specified range.
1.74 -
1.75 - The start of the range is specified by a CBNFNode::KRangeStart()
1.76 - attribute; the end by a CBNFNode::KRangeEnd() attribute. */
1.77 - ERange,
1.78 - /** Select rule: next character must exist in the selected string.
1.79 -
1.80 - If the select string starts with ^, it is a NOT Select. */
1.81 - ESelect,
1.82 - /** And rule: match all of the given sub-rules.
1.83 -
1.84 - Sub-rules are defined by the child nodes of the AND rule node. */
1.85 - EAnd,
1.86 - /** Or rule: match one of the given sub-rules.
1.87 -
1.88 - Sub-rules are defined by the child nodes of the OR rule node. */
1.89 - EOr,
1.90 - /** NMore rule: match a single subrule N or more times.
1.91 -
1.92 - A minimum is specified by a CBNFNode::KNMoreMinimum() attribute; a maximum by
1.93 - a CBNFNode::KNMoreMaximum() attribute; an exact figure by a CBNFNode::KNMoreCount() attribute. */
1.94 - ENMore,
1.95 - /** Optional rule: match a single sub-rule 0/1 times.
1.96 -
1.97 - A sub-rule is defined by the child node of the Optional rule node. */
1.98 - EOptional,
1.99 - /** Without rule: match the first sub-rule but not the second.
1.100 -
1.101 - Sub-rules are defined by the child nodes of the Without rule node. */
1.102 - EWithout,
1.103 - /** Reference rule: match the referred to rule.
1.104 -
1.105 - The target rule name is identified by a CBNFNode::KReference() attribute. */
1.106 - EReference,
1.107 - /** Indicates final node type. */
1.108 - ELastParserNodeType
1.109 - };
1.110 -
1.111 -// Parser states
1.112 -//
1.113 -// When a the state is EActive.
1.114 -// Setting the parser state to something else in a pre-/post-rule callback function
1.115 -// causes the parser to exit on next loop in ParseL. If the state is set to EStopped
1.116 -// we have finished the parser operation (e.g. in event of an error), in state EPaused
1.117 -// we are likely to resume the parser operation after some external operations.
1.118 -/** CBNFParser parser states. */
1.119 -enum TParseState
1.120 - {
1.121 - /** Parser has stopped. */
1.122 - EStopped,
1.123 - /** Rarser is running. */
1.124 - EActive,
1.125 - /** Parser has paused: e.g. waiting for further input to continue. */
1.126 - EPaused
1.127 - };
1.128 -
1.129 -
1.130 -
1.131 -class CBNFParser : public CBase, public MDataProviderObserver
1.132 -/** Base class for parsers that use a BNF tree to parse an input stream.
1.133 -
1.134 -The BNF tree form used is a variation on Extended BNF described in the XML1.0
1.135 -specification. The general form of the tree is as follows:
1.136 -
1.137 -Each node in the tree defines a rule that the input stream must meet to satisfy the grammar.
1.138 -
1.139 -1. a node type is set to the rule type, as defined in TParserNodeTypes
1.140 -
1.141 -2. node data stores any string required by the rule: e.g. for a comparison rule, the string
1.142 - to match against
1.143 -
1.144 -3. the parser allows callback functions to be called either before or after the rule is processed.
1.145 - If these are present, they are stored as attributes of the node.
1.146 -
1.147 -4. some rules allow sub-rules: for example, the AND rule expects a number of sub-rules, all
1.148 - of which must be successful if the AND rule itself is to succeed. Each sub-rule is
1.149 - represented as a child node of the parent rule. Sub-rules in turn can have sub-rules.
1.150 -
1.151 -5. reference rule nodes are also allowed: these do not define themselves rules, but direct the
1.152 - parser to another rule. They can link rules to each other and so build rule sequences more
1.153 - complex than a simple tree.
1.154 -
1.155 -All the top-level rules are stored as attributes of the root node. The attribute type is a string
1.156 - that names the rule; the attribute value is a pointer to the node that implements the rule.
1.157 -
1.158 -The class supplies functions that encapsulate adding rules appropriately to the tree. The parser
1.159 -provider creates a derived class that implements the virtual method TreeL() that uses these
1.160 -functions to create a BNF rule tree.
1.161 -
1.162 -The user of the parser initialises the parser with ResetL(), and then passes input data to the
1.163 -parser using ProcessData(). The parser supports partial parsing: the input stream does not have
1.164 -to completed before parsing can begin. As soon as data is added, the parser attempts to parse it.
1.165 -
1.166 - @publishedAll
1.167 - @released
1.168 -
1.169 -*/
1.170 - {
1.171 -protected:
1.172 - /** Defines a type to handle a stack of rules. */
1.173 - typedef CStack<CBNFNode, EFalse> CRuleStack;
1.174 -
1.175 - /** Type definition for a callback function pointer
1.176 - Callback functions need to get a reference to the parser as parameter
1.177 - and they need to be static. */
1.178 - typedef void (TRuleCallback)(CBNFParser&);
1.179 -
1.180 -public:
1.181 - // Constructor for a new parser instance
1.182 - //
1.183 - // Input:
1.184 - // aLUT - reference to attribute lookuptable; used to store all the stuff in the parser rule tree
1.185 - //
1.186 - //##ModelId=3B6669EA00F8
1.187 - IMPORT_C static CBNFParser* NewL(CAttributeLookupTable& aLUT);
1.188 -
1.189 - //##ModelId=3B6669EA00F7
1.190 - IMPORT_C virtual ~CBNFParser();
1.191 -
1.192 - // Prepare the parser to take in fresh stream of data.
1.193 - // THIS METHOD MUST BE CALLED BEFORE DATA CAN BE PROCESSED BY THE PARSER!!
1.194 - // Calls TreeL in order to create the parsing rule tree if no tree already
1.195 - // exists.
1.196 - //##ModelId=3B6669EA00EF
1.197 - IMPORT_C virtual void ResetL();
1.198 -
1.199 - /** Checks if the input stream was completely processed
1.200 - @return ETrue if all of the data was processed, EFalse if the data didn't match to the parsing rules
1.201 - */
1.202 - //##ModelId=3B6669EA00EE
1.203 - TBool Valid() const { return iStringComplete && (iString.Length() == 0); }
1.204 -
1.205 - /** Concatenates the rest of the input stream (which hasn't yet been processed)
1.206 - into a single string. The ownership of the string is given to the caller.
1.207 - @return String containing the remaining data to be parsed. OWNERSHIP PASSED TO CALLED. */
1.208 - //##ModelId=3B6669EA00ED
1.209 - HBufC* StringL() const { return iString.StringL(); }
1.210 -
1.211 - /** Gets a pointer to the rule node currently being processed.
1.212 - @return Rule node */
1.213 - //##ModelId=3B6669EA00E3
1.214 - CBNFNode* CurrentRule() { return iCurrentRule; }
1.215 -
1.216 - // Set reference to an attribute lookup table
1.217 - //##ModelId=3B6669EA00C5
1.218 - void SetAttributeLookupTable(CAttributeLookupTable& aAttributeLookupTable);
1.219 -
1.220 - // methods to allow the input stream to be marked so that the callbacks
1.221 - // can determine those parts which successfully matched
1.222 -
1.223 - /** Set a mark to the current position of the input stream.
1.224 -
1.225 - The mark acts as a tag in the stream currently being processed.
1.226 - As we process further along the stream after adding the mark, we can perform
1.227 - a rollback to the most previously set mark and start processing again (e.g. OR rule
1.228 - works this way). The string fragments won't be consumed (deleted) until
1.229 - all the marks on a fragment (and fragments before that) are deleted. */
1.230 - //##ModelId=3B6669EA00BC
1.231 - void Mark() { iString.Mark(); }; // **Mark can leave**
1.232 -
1.233 - /** Get string between the "cursor position" and the latest mark on the stream.
1.234 -
1.235 - @return Pointer to the string from the previous mark on to the current position
1.236 - of processed string. OWNERSHIP OF THE STRING GIVEN TO THE CALLER. */
1.237 - //##ModelId=3B6669EA00BB
1.238 - HBufC* MarkedL() { return iString.MarkedL(); };
1.239 -
1.240 - /** Gets the marked string with a string added before the mached string.
1.241 - @see MarkedL()
1.242 - @return A string cosisting of aInitialText appended with the marked string.
1.243 - OWNERSHIP OF THE CONSTRUCTED STRING IS GIVEN TO THE CALLER. */
1.244 - //##ModelId=3B6669EA009E
1.245 - HBufC* MarkedWithInitialTextL(const TDesC& aInitialText) { return iString.MarkedWithInitialTextL(aInitialText); };
1.246 -
1.247 - /** Removes the latest mark. All the marks are stored in a stack and this removes
1.248 - the topmost mark.*/
1.249 - //##ModelId=3B6669EA009D
1.250 - void DeleteMark() { iString.DeleteMark(); };
1.251 -
1.252 - // methods to determine it the used rule actually matched (typically used in post callbacks)
1.253 - /** Tests if the used rule matched.
1.254 -
1.255 - This is typically used in post-rule callbacks.
1.256 -
1.257 - @return True if the used rule matched; otherwise false
1.258 - */
1.259 - //##ModelId=3B6669EA0094
1.260 - TBool RuleMatched() const { return iSubRuleMatched; };
1.261 - /** Tests if an Optional node sub-rule matched.
1.262 -
1.263 - @return True if the sub- rule matched; otherwise false
1.264 - */
1.265 - //##ModelId=3B6669EA0093
1.266 - TBool OptionalMatched() const { return iOptionalMatched; };
1.267 -
1.268 - // Create new rule tree root node.
1.269 - // This method creates a new single instance of CBNFNode, which shall act as the root
1.270 - // node of the rule tree, which implements the BNF rules for parsing the input stream.
1.271 - // All the other rules are attached as attributes to this node.
1.272 - // The root node should have single child node, which should be a reference to the
1.273 - // "logical root" of the rule tree. This can be done be attaching the logical root
1.274 - // rule as a component to the root rule.
1.275 - //##ModelId=3B6669EA0089
1.276 - IMPORT_C CBNFNode* NewBNFL();
1.277 -
1.278 - // Add a new rule to a rule tree.
1.279 - //
1.280 - // Input:
1.281 - // aRootRule - Pointer to the root bnf node (created with NewBNFL() ).
1.282 - // aRuleName - Reference to a string identifying this rule. The string is used
1.283 - // to make references to this rule from other rule's subtrees.
1.284 - // aData - Pointer to a data string; used with EExact and ESelect type rules
1.285 - // to match actual text strings.
1.286 - // aPreRule - Function pointer to a prerule function that gets called _BEFORE_
1.287 - // we start processing this rule and its children (i.e. the rule subtree)
1.288 - // aPostRule - Function pointer to a postrule function which is called _AFTER_
1.289 - // we have processed this rule (i.e. when we return up from the subtree
1.290 - // and this rule is finished).
1.291 - //
1.292 - // Return:
1.293 - // CBNFNode& - Reference to the newly created rule node in the rule tree
1.294 - //
1.295 - //##ModelId=3B6669E90326
1.296 - IMPORT_C CBNFNode& NewRuleL(CBNFNode* aRootRule,
1.297 - const TDesC& aRuleName,
1.298 - TParserNodeTypes aRuleType,
1.299 - HBufC* aData,
1.300 - TRuleCallback* aPreRule,
1.301 - TRuleCallback* aPostRule);
1.302 -
1.303 - // Overridden version of the NewRuleL. Takes reference to the data instead of owning it.
1.304 - //##ModelId=3B6669E903D1
1.305 - IMPORT_C CBNFNode& NewRuleL(CBNFNode* aRootRule,
1.306 - const TDesC& aRuleName,
1.307 - TParserNodeTypes aRuleType,
1.308 - const TDesC& aData,
1.309 - TRuleCallback* aPreRule,
1.310 - TRuleCallback* aPostRule);
1.311 -
1.312 - // construct a new rule component not attached to a rule.
1.313 - //##ModelId=3B6669E9018C
1.314 - IMPORT_C CBNFNode* NewComponentL(TParserNodeTypes aRuleType, const TDesC& aData);
1.315 - //##ModelId=3B6669E901B4
1.316 - IMPORT_C CBNFNode* NewComponentL(TParserNodeTypes aRuleType, HBufC* aData = NULL, TRuleCallback* aPreRule = NULL, TRuleCallback* aPostRule = NULL);
1.317 -
1.318 - // create a reference component to the rule of the given name
1.319 - // which is not attached to any rule.
1.320 - //##ModelId=3B6669E90204
1.321 - IMPORT_C CBNFNode* NewComponentL(CBNFNode* aRootRule, const TDesC& aRuleName);
1.322 -
1.323 - // Methods to create a new subrule to the given parent rule.
1.324 - // These methods can be used to build the subtrees to the "main rules" attached to the root node.
1.325 - //
1.326 - // Input:
1.327 - // aParentRule - The rule for which the new rule shall be added as a child
1.328 - // aRuleType - Type of the new rule
1.329 - // aData - Data for the rule; the string to match for an EExact rule, the selection character set for ESelect
1.330 - //
1.331 - // aPreRule - Pre rule callback function pointer
1.332 - // aPostRule - Post rule callback function pointer
1.333 - // Return:
1.334 - // CBNFNode& - reference to the new rule
1.335 - //
1.336 - //##ModelId=3B6669E9022C
1.337 - IMPORT_C CBNFNode& NewComponentL(CBNFNode &aParentRule, TParserNodeTypes aRuleType, const TDesC& aData);
1.338 - //##ModelId=3B6669E90268
1.339 - IMPORT_C CBNFNode& NewComponentL(CBNFNode &aParentRule, TParserNodeTypes aRuleType, HBufC* aData = NULL, TRuleCallback* aPreRule = NULL, TRuleCallback* aPostRule = NULL);
1.340 -
1.341 - // Create a reference to another rule and attach this reference as a child of the given parent.
1.342 - // Creates a child node of type EReference for the parent. This reference node
1.343 - // hold the pointer to the rule we are refering to.
1.344 - // Using references we can link rules to each other and build complex rule trees
1.345 - // even though they don't physically form a complete tree.
1.346 - // Notice, that the rule we are refering to does not necessarily need to exist, yet!
1.347 - //
1.348 - // Input:
1.349 - // aRootRule - The Root node to the rule tree (created with NewBNFL). This is needed to
1.350 - // find the rule we are refering to with the string.
1.351 - // aParentRule - The parent rule of the newly created reference
1.352 - // aRuleName - The "id string" of the rule we are refering to.
1.353 - //##ModelId=3B6669E902CC
1.354 - IMPORT_C CBNFNode& NewComponentL(CBNFNode* aRootRule, CBNFNode &aParentRule, const TDesC& aRuleName);
1.355 -
1.356 - // add additional attributes to components of rules (i.e. range values)
1.357 - //##ModelId=3B6669E900F6
1.358 - IMPORT_C void AddComponentAttributeL(CBNFNode& aRule, CBNFNodeAttributeType aAttribute, TInt aInt);
1.359 -
1.360 - // re-implementations of MDataProviderObserver methods
1.361 - //##ModelId=3B6669E900D8
1.362 - IMPORT_C virtual void ProcessDataL(HBufC8& aData);
1.363 - //##ModelId=3B6669E900AF
1.364 - IMPORT_C virtual void SetStatus(TInt aStatus = KErrNone);
1.365 - //##ModelId=3B6669E90069
1.366 - IMPORT_C virtual void SetDocumentTypeL(const TDesC&);
1.367 - //##ModelId=3B6669E90087
1.368 - IMPORT_C virtual void SetDocumentTypeL(const TDesC&, const TDesC&);
1.369 - //##ModelId=3B6669E90055
1.370 - IMPORT_C virtual void SetDataExpected(TInt);
1.371 - //##ModelId=3B6669E90041
1.372 - IMPORT_C virtual void SetBaseUriL(const TDesC* aBaseUri);
1.373 - //##ModelId=3B6669E90038
1.374 - IMPORT_C virtual void MDataProviderObserverReserved1();
1.375 - //##ModelId=3B6669E90037
1.376 - IMPORT_C virtual void MDataProviderObserverReserved2();
1.377 -
1.378 - // Tell the parser, that we all the data has been passed in.
1.379 - // This method attempts to parse what ever is left of the input stream if it wasn't
1.380 - // already finished.
1.381 - //##ModelId=3B6669E9002E
1.382 - IMPORT_C void CommitL();
1.383 -
1.384 - /** Get the current state of the parser.
1.385 - @return Parser state */
1.386 - //##ModelId=3B6669E9002D
1.387 - TParseState State() const {return(iParsing);};
1.388 -
1.389 -protected:
1.390 - IMPORT_C CBNFParser(CAttributeLookupTable& aLUT);
1.391 -
1.392 - // Each of the following functions is a handler method for a specific type of a rule
1.393 - // node. For example, ReferenceL handles reference nodes etc.
1.394 - // These methods are called by PerformRuleL.
1.395 - //
1.396 - // Input:
1.397 - // aRule - reference to the rule being processed
1.398 - // aMatched - reference to a CFragmentedString::TStringMatch variable, which holds
1.399 - // the information if the string or character we previously were trying to
1.400 - // match actually matched.
1.401 - // Return:
1.402 - // TBool - We return ETrue if we have completed processing this node. If the processing
1.403 - // still continues we return EFalse. For example, an EAnd rule would return
1.404 - // ETrue if all of its chidren had matched or if a rule didn't match. In the first
1.405 - // case the EAnd rule would have turned out to be true (aMatched = EMatched) since
1.406 - // all of its children were true, but in the latter case we can stop processing the
1.407 - // EAnd rule, since a subrule to the And didn't match and this means that the And
1.408 - // expression can not be true. Either way, the processing of the And ends and we
1.409 - // may return ETrue;
1.410 - //
1.411 - //##ModelId=3B6669E90005
1.412 - IMPORT_C virtual TBool ReferenceL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.413 - //##ModelId=3B6669E803BB
1.414 - IMPORT_C virtual TBool ExactL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.415 - //##ModelId=3B6669E80389
1.416 - IMPORT_C virtual TBool RangeL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.417 - //##ModelId=3B6669E80343
1.418 - IMPORT_C virtual TBool SelectL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.419 - //##ModelId=3B6669E80311
1.420 - IMPORT_C virtual TBool WithoutL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.421 - //##ModelId=3B6669E802D5
1.422 - IMPORT_C virtual TBool AndL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.423 - //##ModelId=3B6669E80299
1.424 - IMPORT_C virtual TBool OrL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.425 - //##ModelId=3B6669E80271
1.426 - IMPORT_C virtual TBool OptionalL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.427 - //##ModelId=3B6669E8023F
1.428 - IMPORT_C virtual TBool NMoreL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.429 -
1.430 - // A method to add a callback to a rule
1.431 - //
1.432 - // Input:
1.433 - // aRule - The rule to which the callback is to be added
1.434 - // aCallbackID - Either CBNFNode::KPreRuleCallback() or CBNFNode::KPostRuleCallback()
1.435 - // Defines the type of the callback function (i.e. is it to be called before
1.436 - // or after the rule has been processed).
1.437 - // aCallback - The callback function pointer
1.438 - //
1.439 - //##ModelId=3B6669E80203
1.440 - IMPORT_C virtual void AddRuleCallbackL(CBNFNode& aRule, const TDesC* aCallbackID, TRuleCallback* aCallback);
1.441 - //##ModelId=3B6669E801EF
1.442 - IMPORT_C virtual void ExecutePreRuleCallbackL(CBNFNode& aRule);
1.443 - //##ModelId=3B6669E801D1
1.444 - IMPORT_C virtual void ExecutePostRuleCallbackL(CBNFNode& aRule);
1.445 -
1.446 - // the method TreeL() should be reimplemented to generate a BNF rule tree and return
1.447 - // ownership of it. This is the rule tree which will be to parse the input stream.
1.448 - // See XmlPars.cpp or DTDMDL.cpp for example.
1.449 - //##ModelId=3B6669E801D0
1.450 - IMPORT_C virtual CBNFNode* TreeL();
1.451 -
1.452 - // methods which are invoked when the parser encounters a conditional
1.453 - // point in the BNF grammar (i.e. And/Or)
1.454 - //##ModelId=3B6669E801B2
1.455 - IMPORT_C virtual void StartConditional(TParserNodeTypes aRuleType);
1.456 - //##ModelId=3B6669E80180
1.457 - IMPORT_C virtual void EndConditional(TParserNodeTypes aRuleType, TBool aSuccess);
1.458 -
1.459 - // A callback function to insert a mark to the current position of the stream
1.460 - // being processed. Adding mark is a very common callback operation befor starting
1.461 - // to process a rule, hence the method is provided by the parser.
1.462 - //##ModelId=3B6669E8016C
1.463 - IMPORT_C static void MarkCallback(CBNFParser& aParser);
1.464 -
1.465 - // returns the LUT used by this parser.
1.466 - //##ModelId=3B6669E80163
1.467 - IMPORT_C CAttributeLookupTable& AttributeLUT() const;
1.468 -
1.469 - // method which does the actual iterative parsing
1.470 - //##ModelId=3B6669E80162
1.471 - IMPORT_C TBool ParseL();
1.472 -
1.473 - // A rule to handle a node in the rule tree. This method just calls the appropriate
1.474 - // handler method according to the rule type.
1.475 - //##ModelId=3B6669E8013A
1.476 - IMPORT_C virtual TBool PerformRuleL(CBNFNode& aRule, CFragmentedString::TStringMatch& aMatched);
1.477 -
1.478 - //##ModelId=3B6669E8011C
1.479 - /** Sets the parser state.
1.480 -
1.481 - @param aState Parser state
1.482 - */
1.483 - void SetState(TParseState aState) {iParsing=aState;};
1.484 -
1.485 -protected:
1.486 - /** Storage object for all the attributes and identifiers in a tree */
1.487 - //##ModelId=3B6669E80108
1.488 - CAttributeLookupTable& iLUT;
1.489 -
1.490 - /** An utility object which stores all the buffers passed into the parser
1.491 - and represents them as if they would form a single, continuous string.
1.492 - This class also performs the actual physical matching/selection of the strings
1.493 - and holds the marks set onto the string.*/
1.494 - //##ModelId=3B6669E800EA
1.495 - CFragmentedString iString;
1.496 - /** Flag indicating if the input stream has been completely processed. */
1.497 - //##ModelId=3B6669E800D6
1.498 - TBool iStringComplete; // more input stream has completed
1.499 -
1.500 - /** The BNF tree the parser is using to parse the input stream.*/
1.501 - //##ModelId=3B6669E800C2
1.502 - CBNFNode* iTree; // the BNF tree we are using to parse the input stream
1.503 -
1.504 - /** A stack of rules from iTree which are waiting to be completed.
1.505 - The stack basically holds the path along the rule tree. */
1.506 - //##ModelId=3B6669E800AE
1.507 - CRuleStack iRuleStack;
1.508 - /** The BNF rule that is currently being processed. */
1.509 - //##ModelId=3B6669E80090
1.510 - CBNFNode* iCurrentRule; // the BNF rule we are currently using
1.511 -
1.512 - // when returning to a rule in the rulestack this indicates
1.513 - // if the child rule matched correctly
1.514 - /** Flag that indicates when returning to a rule in the rulestack if the child rule matched correctly. */
1.515 - //##ModelId=3B6669E8007C
1.516 - TBool iSubRuleMatched;
1.517 - /** Flag that indicates when returning to a rule in the rulestack if an optional rule matched correctly. */
1.518 - //##ModelId=3B6669E8006A
1.519 - TBool iOptionalMatched;
1.520 -
1.521 - /** The child rule we are returning from (if any).
1.522 - If this is NULL we are new to this BNF rule.*/
1.523 - //##ModelId=3B6669E80054
1.524 - CBNFNode* iSubRule;
1.525 -
1.526 - /** Parser state. */
1.527 - //##ModelId=3B6669E8004A
1.528 - TParseState iParsing;
1.529 - /** Input stream matched rule flag. */
1.530 - //##ModelId=3B6669E80038
1.531 - CFragmentedString::TStringMatch iMatched;
1.532 -
1.533 - // Storage pointers for strings identifying certain attributes on the rule nodes
1.534 - /** Stores attribute identifier for reference string attributes. */
1.535 - //##ModelId=3B6669E8002C
1.536 - const TDesC* iReferenceString;
1.537 - /** Stores attribute identifier for range start attributes. */
1.538 - //##ModelId=3B6669E8001A
1.539 - const TDesC* iRangeStart;
1.540 - /** Stores attribute identifier for range end attributes. */
1.541 - //##ModelId=3B6669E80010
1.542 - const TDesC* iRangeEnd;
1.543 - /** Stores attribute identifier for nmore minimum attributes. */
1.544 - //##ModelId=3B6669E80006
1.545 - const TDesC* iMoreMinimum;
1.546 - /** Stores attribute identifier for nmore count attributes. */
1.547 - //##ModelId=3B6669E703DA
1.548 - const TDesC* iMoreCount;
1.549 - /** Stores attribute identifier for nmore maximum attributes. */
1.550 - //##ModelId=3B6669E703D0
1.551 - const TDesC* iMoreMaximum;
1.552 - /** Stores attribute identifier for pre-rule callback attributes. */
1.553 - //##ModelId=3B6669E703C6
1.554 - const TDesC* iPreRuleCallback;
1.555 - /** Stores attribute identifier for post-rule callback attributes. */
1.556 - //##ModelId=3B6669E703BC
1.557 - const TDesC* iPostRuleCallback;
1.558 - };
1.559 -
1.560 -#endif