looks like i had python2 and 3 swapped. java, python3, c# pass. python2, js each have same single test failing: testCharSetWithQuote1

This commit is contained in:
Terence Parr 2015-06-26 12:27:30 -07:00 committed by parrt
parent 99ad09ece1
commit 5d2d75d2e3
23 changed files with 56 additions and 55 deletions

View File

@ -3,11 +3,10 @@ __author__ = 'jszheng'
import optparse import optparse
import sys import sys
import os import os
import importlib
from antlr4 import * from antlr4 import *
# this is a python version of TestRig # this is a python version of TestRig
def beautify_lisp_string(in_string): def beautify_lisp_string(in_string):
indent_size = 3 indent_size = 3

View File

@ -39,11 +39,9 @@
# {@link Token#HIDDEN_CHANNEL}, use a filtering token stream such a # {@link Token#HIDDEN_CHANNEL}, use a filtering token stream such a
# {@link CommonTokenStream}.</p> # {@link CommonTokenStream}.</p>
from io import StringIO from io import StringIO
from antlr4.Token import Token from antlr4.Token import Token
from antlr4.error.Errors import IllegalStateException from antlr4.error.Errors import IllegalStateException
# need forward declaration # need forward declaration
Lexer = None Lexer = None
@ -87,14 +85,14 @@ class BufferedTokenStream(TokenStream):
# {@link #tokens} is trivial with this field.</li> # {@link #tokens} is trivial with this field.</li>
# <ul> # <ul>
self.fetchedEOF = False self.fetchedEOF = False
def mark(self): def mark(self):
return 0 return 0
def release(self, marker:int): def release(self, marker:int):
# no resources to release # no resources to release
pass pass
def reset(self): def reset(self):
self.seek(0) self.seek(0)

View File

@ -4,11 +4,11 @@
# Copyright (c) 2012 Sam Harwell # Copyright (c) 2012 Sam Harwell
# Copyright (c) 2014 Eric Vergnaud # Copyright (c) 2014 Eric Vergnaud
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
# are met: # are met:
# #
# 1. Redistributions of source code must retain the above copyright # 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. # notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright # 2. Redistributions in binary form must reproduce the above copyright
@ -16,7 +16,7 @@
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products # 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission. # derived from this software without specific prior written permission.
# #
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@ -27,16 +27,15 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
# #
# This is an InputStream that is loaded from a file all at once # This is an InputStream that is loaded from a file all at once
# when you construct the object. # when you construct the object.
# #
import codecs import codecs
import unittest import unittest
from antlr4.InputStream import InputStream from antlr4.InputStream import InputStream
@ -57,4 +56,4 @@ class TestFileStream(unittest.TestCase):
def testStream(self): def testStream(self):
stream = FileStream(__file__) stream = FileStream(__file__)
self.assertTrue(stream.size>0) self.assertTrue(stream.size>0)

View File

@ -1,9 +1,7 @@
from io import StringIO from io import StringIO
import unittest import unittest
from antlr4.Token import Token from antlr4.Token import Token
# need forward declarations # need forward declarations
IntervalSet = None IntervalSet = None

View File

@ -31,6 +31,7 @@
from antlr4.IntervalSet import IntervalSet from antlr4.IntervalSet import IntervalSet
from antlr4.Token import Token from antlr4.Token import Token
from antlr4.PredictionContext import PredictionContext, SingletonPredictionContext, PredictionContextFromRuleContext from antlr4.PredictionContext import PredictionContext, SingletonPredictionContext, PredictionContextFromRuleContext
from antlr4.RuleContext import RuleContext
from antlr4.atn.ATN import ATN from antlr4.atn.ATN import ATN
from antlr4.atn.ATNConfig import ATNConfig from antlr4.atn.ATNConfig import ATNConfig
from antlr4.atn.ATNState import ATNState, RuleStopState from antlr4.atn.ATNState import ATNState, RuleStopState
@ -38,7 +39,7 @@ from antlr4.atn.Transition import WildcardTransition, NotSetTransition, Abstract
class LL1Analyzer (object): class LL1Analyzer (object):
#* Special value added to the lookahead sets to indicate that we hit #* Special value added to the lookahead sets to indicate that we hit
# a predicate during analysis if {@code seeThruPreds==false}. # a predicate during analysis if {@code seeThruPreds==false}.
#/ #/

View File

@ -34,14 +34,13 @@
# of speed. # of speed.
#/ #/
from io import StringIO from io import StringIO
from antlr4.CommonTokenFactory import CommonTokenFactory from antlr4.CommonTokenFactory import CommonTokenFactory
from antlr4.atn.LexerATNSimulator import LexerATNSimulator
from antlr4.InputStream import InputStream from antlr4.InputStream import InputStream
from antlr4.Recognizer import Recognizer from antlr4.Recognizer import Recognizer
from antlr4.Token import Token from antlr4.Token import Token
from antlr4.error.Errors import IllegalStateException, LexerNoViableAltException, RecognitionException from antlr4.error.Errors import IllegalStateException, LexerNoViableAltException, RecognitionException
class TokenSource(object): class TokenSource(object):
pass pass
@ -65,7 +64,7 @@ class Lexer(Recognizer, TokenSource):
self._tokenFactorySourcePair = (self, input) self._tokenFactorySourcePair = (self, input)
self._interp = None # child classes must populate this self._interp = None # child classes must populate this
# The goal of all lexer rules/methods is to create a token object. # The goal of all lexer rules/methods is to create a token object.
# self is an instance variable as multiple rules may collaborate to # self is an instance variable as multiple rules may collaborate to
# create a single token. nextToken will return self object after # create a single token. nextToken will return self object after

View File

@ -38,10 +38,9 @@ from antlr4.Token import Token
from antlr4.Lexer import Lexer from antlr4.Lexer import Lexer
from antlr4.atn.ATNDeserializer import ATNDeserializer from antlr4.atn.ATNDeserializer import ATNDeserializer
from antlr4.atn.ATNDeserializationOptions import ATNDeserializationOptions from antlr4.atn.ATNDeserializationOptions import ATNDeserializationOptions
from antlr4.error.Errors import UnsupportedOperationException from antlr4.error.Errors import UnsupportedOperationException, RecognitionException
from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher
from antlr4.tree.Tree import ParseTreeListener from antlr4.tree.Tree import ParseTreeListener, TerminalNode, ErrorNode
class TraceListener(ParseTreeListener): class TraceListener(ParseTreeListener):
@ -163,7 +162,7 @@ class Parser (Recognizer):
# @throws RecognitionException if the current input symbol did not match # @throws RecognitionException if the current input symbol did not match
# a wildcard and the error strategy could not recover from the mismatched # a wildcard and the error strategy could not recover from the mismatched
# symbol # symbol
def matchWildcard(self): def matchWildcard(self):
t = self.getCurrentToken() t = self.getCurrentToken()
if t.type > 0: if t.type > 0:

View File

@ -29,7 +29,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#/ #/
from io import StringIO from io import StringIO
from antlr4.RuleContext import RuleContext from antlr4.RuleContext import RuleContext
from antlr4.atn.ATN import ATN from antlr4.atn.ATN import ATN
from antlr4.atn.ATNState import ATNState from antlr4.atn.ATNState import ATNState
@ -71,7 +70,7 @@ class PredictionContext(object):
# } # }
# </pre> # </pre>
#/ #/
def __init__(self, cachedHashCode:int): def __init__(self, cachedHashCode:int):
self.cachedHashCode = cachedHashCode self.cachedHashCode = cachedHashCode

View File

@ -50,11 +50,9 @@
# @see ParserRuleContext # @see ParserRuleContext
#/ #/
from io import StringIO from io import StringIO
from antlr4.tree.Tree import RuleNode, INVALID_INTERVAL, ParseTreeVisitor from antlr4.tree.Tree import RuleNode, INVALID_INTERVAL, ParseTreeVisitor
from antlr4.tree.Trees import Trees from antlr4.tree.Trees import Trees
# need forward declarations # need forward declarations
RuleContext = None RuleContext = None
Parser = None Parser = None

View File

@ -1 +1,20 @@
from antlr4.Token import Token
from antlr4.InputStream import InputStream
from antlr4.FileStream import FileStream
from antlr4.BufferedTokenStream import TokenStream
from antlr4.CommonTokenStream import CommonTokenStream
from antlr4.Lexer import Lexer
from antlr4.Parser import Parser
from antlr4.dfa.DFA import DFA
from antlr4.atn.ATN import ATN
from antlr4.atn.ATNDeserializer import ATNDeserializer
from antlr4.atn.LexerATNSimulator import LexerATNSimulator
from antlr4.atn.ParserATNSimulator import ParserATNSimulator
from antlr4.atn.PredictionMode import PredictionMode
from antlr4.PredictionContext import PredictionContextCache
from antlr4.ParserRuleContext import ParserRuleContext
from antlr4.tree.Tree import ParseTreeListener, ParseTreeVisitor, ParseTreeWalker, TerminalNode, ErrorNode, RuleNode
from antlr4.error.Errors import RecognitionException, IllegalStateException, NoViableAltException
from antlr4.error.ErrorStrategy import BailErrorStrategy
from antlr4.error.DiagnosticErrorListener import DiagnosticErrorListener
from antlr4.Utils import str_list

View File

@ -37,11 +37,11 @@
# an ATN state. # an ATN state.
#/ #/
from io import StringIO from io import StringIO
from antlr4.PredictionContext import PredictionContext
from antlr4.atn.ATNState import ATNState, DecisionState from antlr4.atn.ATNState import ATNState, DecisionState
from antlr4.atn.LexerActionExecutor import LexerActionExecutor
from antlr4.atn.SemanticContext import SemanticContext from antlr4.atn.SemanticContext import SemanticContext
# need a forward declaration # need a forward declaration
ATNConfig = None ATNConfig = None

View File

@ -34,8 +34,7 @@
# graph-structured stack. # graph-structured stack.
#/ #/
from io import StringIO from io import StringIO
from antlr4.PredictionContext import PredictionContext, merge
from antlr4.PredictionContext import merge
from antlr4.Utils import str_list from antlr4.Utils import str_list
from antlr4.atn.ATN import ATN from antlr4.atn.ATN import ATN
from antlr4.atn.ATNConfig import ATNConfig from antlr4.atn.ATNConfig import ATNConfig

View File

@ -28,7 +28,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#/ #/
from uuid import UUID from uuid import UUID
from io import StringIO
from antlr4.Token import Token from antlr4.Token import Token
from antlr4.atn.ATN import ATN from antlr4.atn.ATN import ATN
from antlr4.atn.ATNType import ATNType from antlr4.atn.ATNType import ATNType
@ -37,7 +37,6 @@ from antlr4.atn.Transition import *
from antlr4.atn.LexerAction import * from antlr4.atn.LexerAction import *
from antlr4.atn.ATNDeserializationOptions import ATNDeserializationOptions from antlr4.atn.ATNDeserializationOptions import ATNDeserializationOptions
# This is the earliest supported serialized UUID. # This is the earliest supported serialized UUID.
BASE_SERIALIZED_UUID = UUID("AADB8D7E-AEEF-4415-AD2B-8204D6CF042E") BASE_SERIALIZED_UUID = UUID("AADB8D7E-AEEF-4415-AD2B-8204D6CF042E")
@ -165,8 +164,8 @@ class ATNDeserializer (object):
for i in range(0, numPrecedenceStates): for i in range(0, numPrecedenceStates):
stateNumber = self.readInt() stateNumber = self.readInt()
atn.states[stateNumber].isPrecedenceRule = True atn.states[stateNumber].isPrecedenceRule = True
def readRules(self, atn:ATN): def readRules(self, atn:ATN):
nrules = self.readInt() nrules = self.readInt()
if atn.grammarType == ATNType.LEXER: if atn.grammarType == ATNType.LEXER:
atn.ruleToTokenType = [0] * nrules atn.ruleToTokenType = [0] * nrules

View File

@ -257,7 +257,6 @@
# the input.</p> # the input.</p>
# #
import sys import sys
from antlr4 import DFA from antlr4 import DFA
from antlr4.PredictionContext import PredictionContextCache, PredictionContext, SingletonPredictionContext, \ from antlr4.PredictionContext import PredictionContextCache, PredictionContext, SingletonPredictionContext, \
PredictionContextFromRuleContext PredictionContextFromRuleContext
@ -273,7 +272,7 @@ from antlr4.atn.ATNConfigSet import ATNConfigSet
from antlr4.atn.ATNSimulator import ATNSimulator from antlr4.atn.ATNSimulator import ATNSimulator
from antlr4.atn.ATNState import StarLoopEntryState, DecisionState, RuleStopState, ATNState from antlr4.atn.ATNState import StarLoopEntryState, DecisionState, RuleStopState, ATNState
from antlr4.atn.PredictionMode import PredictionMode from antlr4.atn.PredictionMode import PredictionMode
from antlr4.atn.SemanticContext import SemanticContext, andContext, orContext from antlr4.atn.SemanticContext import SemanticContext, AND, andContext, orContext
from antlr4.atn.Transition import Transition, RuleTransition, ActionTransition, PrecedencePredicateTransition, \ from antlr4.atn.Transition import Transition, RuleTransition, ActionTransition, PrecedencePredicateTransition, \
PredicateTransition, AtomTransition, SetTransition, NotSetTransition PredicateTransition, AtomTransition, SetTransition, NotSetTransition
from antlr4.dfa.DFAState import DFAState, PredPrediction from antlr4.dfa.DFAState import DFAState, PredPrediction
@ -322,7 +321,7 @@ class ParserATNSimulator(ATNSimulator):
self._input = input self._input = input
self._startIndex = input.index self._startIndex = input.index
self._outerContext = outerContext self._outerContext = outerContext
dfa = self.decisionToDFA[decision] dfa = self.decisionToDFA[decision]
self._dfa = dfa self._dfa = dfa
m = input.mark() m = input.mark()
@ -708,7 +707,7 @@ class ParserATNSimulator(ATNSimulator):
# For full-context reach operations, separate handling is required to # For full-context reach operations, separate handling is required to
# ensure that the alternative matching the longest overall sequence is # ensure that the alternative matching the longest overall sequence is
# chosen when multiple such configurations can match the input. # chosen when multiple such configurations can match the input.
skippedStopStates = None skippedStopStates = None
# First figure out where we can reach on input t # First figure out where we can reach on input t

View File

@ -37,7 +37,6 @@
# {@link SemanticContext} within the scope of this outer class.</p> # {@link SemanticContext} within the scope of this outer class.</p>
# #
from io import StringIO from io import StringIO
from antlr4.Recognizer import Recognizer from antlr4.Recognizer import Recognizer
from antlr4.RuleContext import RuleContext from antlr4.RuleContext import RuleContext
@ -359,4 +358,4 @@ class OR (SemanticContext):
return buf.getvalue() return buf.getvalue()
SemanticContext.NONE = Predicate() SemanticContext.NONE = Predicate()

View File

@ -31,7 +31,6 @@
# A DFA walker that knows how to dump them to serialized strings.#/ # A DFA walker that knows how to dump them to serialized strings.#/
from io import StringIO from io import StringIO
from antlr4 import DFA from antlr4 import DFA
from antlr4.Utils import str_list from antlr4.Utils import str_list
from antlr4.dfa.DFAState import DFAState from antlr4.dfa.DFAState import DFAState

View File

@ -31,7 +31,7 @@
# Map a predicate to a predicted alternative.#/ # Map a predicate to a predicted alternative.#/
from io import StringIO from io import StringIO
from antlr4.atn.ATNConfigSet import ATNConfigSet
from antlr4.atn.SemanticContext import SemanticContext from antlr4.atn.SemanticContext import SemanticContext

View File

@ -50,12 +50,10 @@
# </ul> # </ul>
from io import StringIO from io import StringIO
from antlr4 import Parser, DFA from antlr4 import Parser, DFA
from antlr4.atn.ATNConfigSet import ATNConfigSet from antlr4.atn.ATNConfigSet import ATNConfigSet
from antlr4.error.ErrorListener import ErrorListener from antlr4.error.ErrorListener import ErrorListener
class DiagnosticErrorListener(ErrorListener): class DiagnosticErrorListener(ErrorListener):
def __init__(self, exactOnly:bool=True): def __init__(self, exactOnly:bool=True):

View File

@ -28,6 +28,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
import sys
from antlr4.IntervalSet import IntervalSet from antlr4.IntervalSet import IntervalSet
from antlr4.Token import Token from antlr4.Token import Token
@ -722,4 +723,4 @@ class BailErrorStrategy(DefaultErrorStrategy):
def sync(self, recognizer:Parser): def sync(self, recognizer:Parser):
pass pass
del Parser del Parser

View File

@ -60,7 +60,8 @@ class CancellationException(IllegalStateException):
# and what kind of problem occurred. # and what kind of problem occurred.
from antlr4.InputStream import InputStream from antlr4.InputStream import InputStream
from antlr4.ParserRuleContext import ParserRuleContext
from antlr4.Recognizer import Recognizer
class RecognitionException(Exception): class RecognitionException(Exception):

View File

@ -34,7 +34,6 @@
# Represents the result of matching a {@link ParseTree} against a tree pattern. # Represents the result of matching a {@link ParseTree} against a tree pattern.
# #
from io import StringIO from io import StringIO
from antlr4.tree.ParseTreePattern import ParseTreePattern from antlr4.tree.ParseTreePattern import ParseTreePattern
from antlr4.tree.Tree import ParseTree from antlr4.tree.Tree import ParseTree

View File

@ -32,12 +32,10 @@
# A set of utility routines useful for all kinds of ANTLR trees.# # A set of utility routines useful for all kinds of ANTLR trees.#
from io import StringIO from io import StringIO
from antlr4.Token import Token from antlr4.Token import Token
from antlr4.Utils import escapeWhitespace from antlr4.Utils import escapeWhitespace
from antlr4.tree.Tree import RuleNode, ErrorNode, TerminalNode, Tree, ParseTree from antlr4.tree.Tree import RuleNode, ErrorNode, TerminalNode, Tree, ParseTree
# need forward declaration # need forward declaration
Parser = None Parser = None

View File

@ -42,8 +42,7 @@
# <p> # <p>
# Whitespace is not allowed.</p> # Whitespace is not allowed.</p>
# #
from io import StringIO from xmlrpc.client import boolean
from antlr4 import CommonTokenStream, DFA, PredictionContextCache, Lexer, LexerATNSimulator, ParserRuleContext, TerminalNode from antlr4 import CommonTokenStream, DFA, PredictionContextCache, Lexer, LexerATNSimulator, ParserRuleContext, TerminalNode
from antlr4.InputStream import InputStream from antlr4.InputStream import InputStream
from antlr4.Parser import Parser from antlr4.Parser import Parser
@ -55,6 +54,7 @@ from antlr4.tree.Tree import ParseTree
from antlr4.tree.Trees import Trees from antlr4.tree.Trees import Trees
from antlr4.atn.ATNDeserializer import ATNDeserializer from antlr4.atn.ATNDeserializer import ATNDeserializer
from io import StringIO
def serializedATN(): def serializedATN():
with StringIO() as buf: with StringIO() as buf:
@ -344,4 +344,4 @@ class XPathWildcardElement(XPathElement):
if self.invert: if self.invert:
return list() # !* is weird but valid (empty) return list() # !* is weird but valid (empty)
else: else:
return Trees.getChildren(t) return Trees.getChildren(t)