Merge branch 'master' into fix-js-docs
This commit is contained in:
commit
381aede6fd
|
@ -249,8 +249,10 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2020/02/21, StochasticTinkr, Daniel Pitts, github@coloraura.com
|
||||
2020/03/17, XsongyangX, Song Yang, songyang1218@gmail.com
|
||||
2020/04/07, deniskyashif, Denis Kyashif, denis.kyashif@gmail.com
|
||||
2020/04/23, martinvw, Martin van Wingerden, martin@martinvw.nl
|
||||
2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com
|
||||
2020/05/06, iammosespaulr, Moses Paul R, iammosespaulr@gmail.com
|
||||
2020/05/10, gomerser, Erik Gomersbach, gomerser@gomersba.ch
|
||||
2020/06/04, sigmasoldi3r, Pablo Blanco, pablobc.1995@gmail.com
|
||||
2020/05/25, graknol, Sindre van der Linden, graknol@gmail.com
|
||||
2020/05/31, d-markey, David Markey, dmarkey@free.fr
|
||||
|
@ -263,4 +265,6 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2020/09/15, rmcgregor1990, Robert McGregor, rmcgregor1990@gmail.com
|
||||
2020/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net
|
||||
2020/10/08, Marti2203, Martin Mirchev, mirchevmartin2203@gmail.com
|
||||
2020/10/16, adarshbhat, Adarsh Bhat, mail@adarshbhat.com
|
||||
2020/10/16, adarshbhat, Adarsh Bhat, adarshbhat@users.noreply.github.com
|
||||
2020/10/20, adamwojs, Adam Wójs, adam[at]wojs.pl
|
||||
2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com
|
||||
|
|
|
@ -1057,4 +1057,33 @@ public class LexerExecDescriptors {
|
|||
return new Pair<>(grammarName, grammar);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a regression test for antlr/antlr4#2709 "PHP target generates
|
||||
* invalid output when $ is used as part of the literal in lexer rule"
|
||||
* https://github.com/antlr/antlr4/issues/2709
|
||||
*/
|
||||
public static class EscapeTargetStringLiteral extends BaseLexerTestDescriptor {
|
||||
/**
|
||||
[@0,0:-1='<EOF>',<-1>,1:0]
|
||||
*/
|
||||
@CommentHasStringValue
|
||||
public String output;
|
||||
|
||||
public String errors = null;
|
||||
public String startRule = "";
|
||||
public String grammarName = "L";
|
||||
|
||||
/**
|
||||
lexer grammar L;
|
||||
ACTION_WITH_DOLLAR: '$ACTION';
|
||||
*/
|
||||
@CommentHasStringValue
|
||||
public String grammar;
|
||||
|
||||
@Override
|
||||
public boolean ignore(String targetName) {
|
||||
return !targetName.equals("PHP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,12 @@
|
|||
# of speed.
|
||||
#/
|
||||
from io import StringIO
|
||||
from typing.io import TextIO
|
||||
|
||||
import sys
|
||||
if sys.version_info[1] > 5:
|
||||
from typing import TextIO
|
||||
else:
|
||||
from typing.io import TextIO
|
||||
from antlr4.CommonTokenFactory import CommonTokenFactory
|
||||
from antlr4.atn.LexerATNSimulator import LexerATNSimulator
|
||||
from antlr4.InputStream import InputStream
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
# Use of this file is governed by the BSD 3-clause license that
|
||||
# can be found in the LICENSE.txt file in the project root.
|
||||
import sys
|
||||
from typing.io import TextIO
|
||||
if sys.version_info[1] > 5:
|
||||
from typing import TextIO
|
||||
else:
|
||||
from typing.io import TextIO
|
||||
from antlr4.BufferedTokenStream import TokenStream
|
||||
from antlr4.CommonTokenFactory import TokenFactory
|
||||
from antlr4.error.ErrorStrategy import DefaultErrorStrategy
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
import Foundation
|
||||
|
||||
public class ParseTreeProperty<V> {
|
||||
var annotations = Dictionary<ObjectIdentifier, V>()
|
||||
|
||||
public init() {}
|
||||
|
||||
open func get(_ node: ParseTree) -> V? { return annotations[ObjectIdentifier(node)] }
|
||||
open func put(_ node: ParseTree, _ value: V) { annotations[ObjectIdentifier(node)] = value }
|
||||
open func removeFrom(_ node: ParseTree) { annotations.removeValue(forKey: ObjectIdentifier(node)) }
|
||||
}
|
|
@ -138,13 +138,13 @@ import Antlr4
|
|||
*
|
||||
* \<p>The default implementation does nothing.\</p>
|
||||
*/
|
||||
<accessLevelOpenOK(file)> func enterEveryRule(_ ctx: ParserRuleContext) { }
|
||||
<accessLevelOpenOK(file)> func enterEveryRule(_ ctx: ParserRuleContext) throws { }
|
||||
/**
|
||||
* {@inheritDoc\}
|
||||
*
|
||||
* \<p>The default implementation does nothing.\</p>
|
||||
*/
|
||||
<accessLevelOpenOK(file)> func exitEveryRule(_ ctx: ParserRuleContext) { }
|
||||
<accessLevelOpenOK(file)> func exitEveryRule(_ ctx: ParserRuleContext) throws { }
|
||||
/**
|
||||
* {@inheritDoc\}
|
||||
*
|
||||
|
@ -438,10 +438,10 @@ LeftRecursiveRuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,
|
|||
@discardableResult
|
||||
private func <currentRule.name>(_ _p<args:{a | , <a>}>: Int) throws -> <currentRule.ctxType> {
|
||||
let _parentctx: ParserRuleContext? = _ctx
|
||||
var _parentState: Int = getState()
|
||||
let _parentState: Int = getState()
|
||||
var _localctx: <currentRule.ctxType> = <currentRule.ctxType>(_ctx, _parentState<currentRule.args:{a | , <a.name>}>)
|
||||
var _prevctx: <currentRule.ctxType> = _localctx
|
||||
var _startState: Int = <currentRule.startState>
|
||||
var _prevctx: <currentRule.ctxType> = _localctx
|
||||
let _startState: Int = <currentRule.startState>
|
||||
try enterRecursionRule(_localctx, <currentRule.startState>, <parser.name>.RULE_<currentRule.name>, _p)
|
||||
<namedActions.init>
|
||||
<locals; separator="\n">
|
||||
|
|
|
@ -102,4 +102,12 @@ public class PHPTarget extends Target {
|
|||
protected void appendUnicodeEscapedCodePoint(int codePoint, StringBuilder sb) {
|
||||
UnicodeEscapes.appendPythonStyleEscapedCodePoint(codePoint, sb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes) {
|
||||
String targetStringLiteral = super.getTargetStringLiteralFromANTLRStringLiteral(generator, literal, addQuotes);
|
||||
targetStringLiteral = targetStringLiteral.replace("$", "\\$");
|
||||
|
||||
return targetStringLiteral;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue