Skip to content

Commit 547a396

Browse files
Remotes/origin/kritkasahni gae py3 search (#78)
* added search and deps * added __init__.py in _internal * added document pb * remove broken tests; will fix as part of backlog * .DS_Store banished * Update tox config to run antlr3 UTs
1 parent cc19a2e commit 547a396

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+43465
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
__pycache__
33
src/appengine_python_standard.egg-info
44
.tox
5+
.DS_Store

src/google/appengine/_internal/__init__.py

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[The "BSD licence"]
2+
Copyright (c) 2003-2008 Terence Parr
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions
7+
are met:
8+
9+
1. Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
3. The name of the author may not be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2007 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
""" @package google.appengine._internal.antlr3
18+
@brief ANTLR3 runtime package
19+
20+
This module contains all support classes, which are needed to use recognizers
21+
generated by ANTLR3.
22+
23+
@mainpage
24+
25+
\note Please be warned that the line numbers in the API documentation do not
26+
match the real locations in the source code of the package. This is an
27+
unintended artifact of doxygen, which I could only convince to use the
28+
correct module names by concatenating all files from the package into a single
29+
module file...
30+
31+
Here is a little overview over the most commonly used classes provided by
32+
this runtime:
33+
34+
@section recognizers Recognizers
35+
36+
These recognizers are baseclasses for the code which is generated by ANTLR3.
37+
38+
- BaseRecognizer: Base class with common recognizer functionality.
39+
- Lexer: Base class for lexers.
40+
- Parser: Base class for parsers.
41+
- tree.TreeParser: Base class for %tree parser.
42+
43+
@section streams Streams
44+
45+
Each recognizer pulls its input from one of the stream classes below. Streams
46+
handle stuff like buffering, look-ahead and seeking.
47+
48+
A character stream is usually the first element in the pipeline of a typical
49+
ANTLR3 application. It is used as the input for a Lexer.
50+
51+
- ANTLRStringStream: Reads from a string objects. The input should be a unicode
52+
object, or ANTLR3 will have trouble decoding non-ascii data.
53+
- ANTLRFileStream: Opens a file and read the contents, with optional character
54+
decoding.
55+
- ANTLRInputStream: Reads the date from a file-like object, with optional
56+
character decoding.
57+
58+
A Parser needs a TokenStream as input (which in turn is usually fed by a
59+
Lexer):
60+
61+
- CommonTokenStream: A basic and most commonly used TokenStream
62+
implementation.
63+
- TokenRewriteStream: A modification of CommonTokenStream that allows the
64+
stream to be altered (by the Parser). See the 'tweak' example for a usecase.
65+
66+
And tree.TreeParser finally fetches its input from a tree.TreeNodeStream:
67+
68+
- tree.CommonTreeNodeStream: A basic and most commonly used tree.TreeNodeStream
69+
implementation.
70+
71+
72+
@section tokenstrees Tokens and Trees
73+
74+
A Lexer emits Token objects which are usually buffered by a TokenStream. A
75+
Parser can build a Tree, if the output=AST option has been set in the grammar.
76+
77+
The runtime provides these Token implementations:
78+
79+
- CommonToken: A basic and most commonly used Token implementation.
80+
- ClassicToken: A Token object as used in ANTLR 2.x, used to %tree
81+
construction.
82+
83+
Tree objects are wrapper for Token objects.
84+
85+
- tree.CommonTree: A basic and most commonly used Tree implementation.
86+
87+
A tree.TreeAdaptor is used by the parser to create tree.Tree objects for the
88+
input Token objects.
89+
90+
- tree.CommonTreeAdaptor: A basic and most commonly used tree.TreeAdaptor
91+
implementation.
92+
93+
94+
@section Exceptions
95+
96+
RecognitionException are generated, when a recognizer encounters incorrect
97+
or unexpected input.
98+
99+
- RecognitionException
100+
- MismatchedRangeException
101+
- MismatchedSetException
102+
- MismatchedNotSetException
103+
.
104+
- MismatchedTokenException
105+
- MismatchedTreeNodeException
106+
- NoViableAltException
107+
- EarlyExitException
108+
- FailedPredicateException
109+
.
110+
.
111+
112+
A tree.RewriteCardinalityException is raised, when the parsers hits a
113+
cardinality mismatch during AST construction. Although this is basically a
114+
bug in your grammar, it can only be detected at runtime.
115+
116+
- tree.RewriteCardinalityException
117+
- tree.RewriteEarlyExitException
118+
- tree.RewriteEmptyStreamException
119+
.
120+
.
121+
122+
"""
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
__version__ = '3.1.1'
158+
159+
def version_str_to_tuple(version_str):
160+
import re
161+
import sys
162+
163+
if version_str == 'HEAD':
164+
return (sys.maxsize, sys.maxsize, sys.maxsize, sys.maxsize)
165+
166+
m = re.match(r'(\d+)\.(\d+)(\.(\d+))?(b(\d+))?', version_str)
167+
if m is None:
168+
raise ValueError('Bad version string %r' % version_str)
169+
170+
major = int(m.group(1))
171+
minor = int(m.group(2))
172+
patch = int(m.group(4) or 0)
173+
beta = int(m.group(6) or sys.maxsize)
174+
175+
return (major, minor, patch, beta)
176+
177+
178+
runtime_version_str = __version__
179+
runtime_version = version_str_to_tuple(runtime_version_str)
180+
181+
from .exceptions import *
182+
183+
from .constants import *
184+
from .dfa import *
185+
from .recognizers import *
186+
from .streams import *
187+
from .tokens import *
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2007 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
"""Compatibility stuff"""
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+
try:
50+
set = set
51+
frozenset = frozenset
52+
except NameError:
53+
from sets import Set as set, ImmutableSet as frozenset
54+
55+
56+
try:
57+
reversed = reversed
58+
except NameError:
59+
60+
def reversed(l):
61+
l = l[:]
62+
l.reverse()
63+
return l
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2007 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
"""ANTLR3 runtime package"""
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+
EOF = -1
50+
51+
52+
53+
54+
DEFAULT_CHANNEL = 0
55+
56+
57+
58+
HIDDEN_CHANNEL = 99
59+
60+
61+
EOR_TOKEN_TYPE = 1
62+
63+
64+
65+
DOWN = 2
66+
67+
68+
UP = 3
69+
70+
MIN_TOKEN_TYPE = UP+1
71+
72+
INVALID_TOKEN_TYPE = 0

0 commit comments

Comments
 (0)