Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef ADC_TKPCONT2_HXX
21 : #define ADC_TKPCONT2_HXX
22 :
23 : // USED SERVICES
24 : // BASE CLASSES
25 : // COMPONENTS
26 : // PARAMETERS
27 : class CharacterSource;
28 : class TkpNullContext;
29 : class TkpNullContex2;
30 :
31 : /** @task
32 : Specifies a context within which tokens are interpreted in a special
33 : way. For example in parsing C++ there could be a context for code,
34 : one for comments and a third one for preprocessor statements, because
35 : each of these would give the same token different meanings.
36 : **/
37 39 : class TkpContext
38 : {
39 : public:
40 : // LIFECYCLE
41 0 : virtual ~TkpContext() {}
42 :
43 : // OPERATIONS
44 : /** @descr
45 : The functions starts to parse with the CurToken() of io_rText.
46 : It leaves io_rText at the first char of the following Token or
47 : the following Context.
48 :
49 : This function returns, when a context has parsed some characterss
50 : and completed a token OR left the context.
51 : If the token is to be ignored, PassNewToken() returns false
52 : and cuts the token from io_rText.
53 : If the token is to be parsed further in a different context,
54 : PassNewToken() returns false, but the token is
55 : NOT cut from io_rText.
56 :
57 : If the function has found a valid and complete token, PassNewToken()
58 : passes the parsed token to the internally known receiver and
59 : returns true. The token is cut from io_rText.
60 : **/
61 : virtual void ReadCharChain(
62 : CharacterSource & io_rText ) = 0;
63 : /** Has to pass the parsed token to a known receiver.
64 : @return true, if a token was passed.
65 : false, if no token was parsed complete by this context.
66 : */
67 : virtual bool PassNewToken() = 0;
68 : virtual TkpContext &
69 : FollowUpContext() = 0;
70 :
71 : static TkpNullContext &
72 : Null_();
73 : };
74 :
75 : TkpNullContex2 & TkpContext_Null2_();
76 :
77 6 : class StateMachineContext
78 : {
79 : public:
80 6 : virtual ~StateMachineContext() {}
81 :
82 : /// Is used by StmBoundsStatu2 only.
83 : virtual void PerformStatusFunction(
84 : uintt i_nStatusSignal,
85 : UINT16 i_nTokenId,
86 : CharacterSource & io_rText ) = 0;
87 : };
88 :
89 : class TkpNullContex2 : public TkpContext
90 : {
91 : public:
92 : ~TkpNullContex2();
93 :
94 : virtual void ReadCharChain(
95 : CharacterSource & io_rText );
96 : virtual bool PassNewToken();
97 : virtual TkpContext &
98 : FollowUpContext();
99 : };
100 :
101 6 : class TkpDocuContext : public TkpContext
102 : {
103 : public:
104 : virtual void SetParentContext(
105 : TkpContext & io_rParentContext,
106 : const char * i_sMultiLineEndToken ) = 0;
107 : virtual void SetMode_IsMultiLine(
108 : bool i_bTrue ) = 0;
109 : };
110 :
111 :
112 :
113 : #endif
114 :
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|