1
// This file is part of PUMA.
2
// Copyright (C) 1999-2003 The PUMA developer team.
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License as
6
// published by the Free Software Foundation; either version 2 of
7
// the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public
15
// License along with this program; if not, write to the Free
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19
#include "Puma/OrangeRecognizer.h"
20
#include "Puma/ScanBuffer.h"
27
// try to recognize the current token in the character buffer
28
// returns 1 on success, 0 on unknown token, -1 on buffer error
30
//int OrangeRecognizer::recognize (ScanBuffer *scan_buffer, int &token, int &len) {
39
// ScanBuffer::State buffer_state = ScanBuffer::STATE_OK;
47
// Character = scan_buffer->next ();
49
// CharClass = _map[(unsigned char)Character];
50
// if (CharClass == -1)
53
// NextStatePos = _state[State].Start + CharClass;
54
// if (NextStatePos < 0 || NextStatePos >= _tab_size ||
55
// _control[NextStatePos] != State)
58
// if ((NextState = _next[NextStatePos]) == -1)
63
// if (_state[State].Type > 0) {
64
// AcceptState = State; // remember this (terminal) state
65
// AcceptLen = scan_buffer->len ();
68
// if (_state[State].LookAhead)
69
// LookAheadLen = scan_buffer->len ();
71
// buffer_state = scan_buffer->state ();
72
// } while (NextState != -1 && buffer_state == ScanBuffer::STATE_OK);
74
// if (buffer_state == ScanBuffer::STATE_ERROR)
77
// if (AcceptState == -1)
80
// len = (_state[AcceptState].Type == 2) ? LookAheadLen : AcceptLen;
81
// token = _state[AcceptState].Expression;