summaryrefslogtreecommitdiff
path: root/src/parser/bounded_token_buffer.h
blob: 415f6062ffe9f7888fa296ea789f38ccb0cfe4fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*********************                                                        */
/*! \file bounded_token_buffer.h
 ** \verbatim
 ** Original author: cconway
 ** Major contributors: mdeters
 ** Minor contributors (to current version): none
 ** This file is part of the CVC4 prototype.
 ** Copyright (c) 2009-2012  New York University and The University of Iowa
 ** See the file COPYING in the top-level source directory for licensing
 ** information.\endverbatim
 **
 ** \brief An ANTLR3 bounded token stream.
 **
 ** An ANTLR3 bounded token stream. The stream has a bounded
 ** lookahead/behind k. Calling LT(i) with i > k or i < -k will raise
 ** an exception. Only use this factory if you *know* that the grammar
 ** has bounded lookahead (e.g., if you've set the k parameter in the 
 ** parser.
 **
 ** NOTE: ANTLR3 puts "hidden" tokens into this buffer too, so
 ** pathological inputs can exceed the k token lookahead, even if
 ** your grammar really is LL(k). Be sure that irrelevant tokens
 ** are SKIP()'d and not "hidden".
 **/

#include "cvc4parser_private.h"

#ifndef	__CVC4__PARSER__BOUNDED_TOKEN_BUFFER_H
#define	__CVC4__PARSER__BOUNDED_TOKEN_BUFFER_H

#include <antlr3defs.h>

namespace CVC4 {
namespace parser {

#ifdef __cplusplus
extern "C" {
#endif


/** A "super" structure for COMMON_TOKEN_STREAM. */
typedef struct BOUNDED_TOKEN_BUFFER_struct
{
    pANTLR3_COMMON_TOKEN_STREAM    commonTstream;
    pANTLR3_COMMON_TOKEN* tokenBuffer;
    // tokenNeg1, token1, token2;
    ANTLR3_UINT32 currentIndex, maxIndex, k, bufferSize;
    ANTLR3_BOOLEAN empty, done;
} BOUNDED_TOKEN_BUFFER, *pBOUNDED_TOKEN_BUFFER;

pBOUNDED_TOKEN_BUFFER
BoundedTokenBufferSourceNew(ANTLR3_UINT32 k, pANTLR3_TOKEN_SOURCE source);

void
BoundedTokenBufferFree(pBOUNDED_TOKEN_BUFFER buffer);

#ifdef __cplusplus
}/* extern "C" */
#endif

}/* CVC4::parser namespace */
}/* CVC4 namespace */

#endif /* __CVC4__PARSER__BOUNDED_TOKEN_BUFFER_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback