automaton.hpp
Go to the documentation of this file.
1
/*----------------------------------------------------------------------------*/
2
/* */
3
/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4
/* Copyright (c) 2005-2014 Rexx Language Association. All rights reserved. */
5
/* */
6
/* This program and the accompanying materials are made available under */
7
/* the terms of the Common Public License v1.0 which accompanies this */
8
/* distribution. A copy is also available at the following address: */
9
/* https://www.oorexx.org/license.html */
10
/* */
11
/* Redistribution and use in source and binary forms, with or */
12
/* without modification, are permitted provided that the following */
13
/* conditions are met: */
14
/* */
15
/* Redistributions of source code must retain the above copyright */
16
/* notice, this list of conditions and the following disclaimer. */
17
/* Redistributions in binary form must reproduce the above copyright */
18
/* notice, this list of conditions and the following disclaimer in */
19
/* the documentation and/or other materials provided with the distribution. */
20
/* */
21
/* Neither the name of Rexx Language Association nor the names */
22
/* of its contributors may be used to endorse or promote products */
23
/* derived from this software without specific prior written permission. */
24
/* */
25
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36
/* */
37
/*----------------------------------------------------------------------------*/
38
/******************************************************************************/
39
/* Object REXX Support */
40
/* */
41
/* Regular Expression Utility functions - automaton header file */
42
/* */
43
/******************************************************************************/
44
45
#ifndef AUTOMATON
46
#define AUTOMATON
47
48
#include "
dblqueue.hpp
"
49
50
class
automaton
{
51
public
:
52
automaton
();
// CTOR
53
~automaton
();
// DTOR
54
int
parse
(
const
char
*);
// parse regular expression
55
int
match
(
const
char
*,
int
);
// match a string
56
57
// in case of a parsing error, this can be used
58
// to detect the position at which the error
59
// occured. on successful parsing it tells the
60
// length of the regular expression.
61
int
getCurrentPos
() {
return
currentPos
; }
62
63
void
setMinimal
(
bool
);
64
bool
getMinimal
() {
return
minimal
; }
65
66
private
:
67
// methods to parse a regular expression
68
int
expression
();
69
int
term
();
70
int
factor
();
71
int
set
();
72
int
letter
(
int
);
73
74
// insert a state into the automaton
75
void
setState
(
int
,
int
,
int
,
int
);
76
// insert a set into the list of sets
77
int
insertSet
(
char
*,
int
);
78
// helper function for set building
79
int
checkRange
(
char
*,
int
,
char
);
80
81
int
*
ch
;
// characters to match
82
int
*
next1
;
// first transition possibility
83
int
*
next2
;
// second transition possibility
84
85
int
final
;
// the final state position
86
87
const
char
*
regexp
;
// pointer to regular expression
88
89
int
**
setArray
;
// pointer to array of sets
90
int
setSize
;
// number of sets
91
92
int
size
;
// number of states
93
int
freeState
;
// number of next free state
94
int
currentPos
;
// current position in parsing
95
bool
minimal
;
// minimal matching?
96
};
97
98
#endif
automaton
Definition:
automaton.hpp:50
automaton::getCurrentPos
int getCurrentPos()
Definition:
automaton.hpp:61
automaton::set
int set()
Definition:
automaton.cpp:545
automaton::checkRange
int checkRange(char *, int, char)
Definition:
automaton.cpp:737
automaton::match
int match(const char *, int)
Definition:
automaton.cpp:783
automaton::automaton
automaton()
Definition:
automaton.cpp:53
automaton::expression
int expression()
Definition:
automaton.cpp:325
automaton::regexp
const char * regexp
Definition:
automaton.hpp:87
automaton::currentPos
int currentPos
Definition:
automaton.hpp:94
automaton::setSize
int setSize
Definition:
automaton.hpp:90
automaton::insertSet
int insertSet(char *, int)
Definition:
automaton.cpp:759
automaton::setState
void setState(int, int, int, int)
Definition:
automaton.cpp:714
automaton::minimal
bool minimal
Definition:
automaton.hpp:95
automaton::ch
int * ch
Definition:
automaton.hpp:81
automaton::letter
int letter(int)
Definition:
automaton.cpp:293
automaton::~automaton
~automaton()
Definition:
automaton.cpp:64
automaton::freeState
int freeState
Definition:
automaton.hpp:93
automaton::size
int size
Definition:
automaton.hpp:92
automaton::next1
int * next1
Definition:
automaton.hpp:82
automaton::parse
int parse(const char *)
Definition:
automaton.cpp:191
automaton::getMinimal
bool getMinimal()
Definition:
automaton.hpp:64
automaton::term
int term()
Definition:
automaton.cpp:355
automaton::next2
int * next2
Definition:
automaton.hpp:83
automaton::factor
int factor()
Definition:
automaton.cpp:387
automaton::setArray
int ** setArray
Definition:
automaton.hpp:89
automaton::setMinimal
void setMinimal(bool)
Definition:
automaton.cpp:90
dblqueue.hpp
oorexx
executor
sandbox
jlf
trunk
extensions
rxregexp
automaton.hpp
Generated by
1.9.2