forked from jasder/antlr
Merge branch 'master' into master
This commit is contained in:
commit
e3243f74b2
|
@ -208,6 +208,7 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com
|
||||
2018/07/27, Maksim Novikov, mnovikov.work@gmail.com
|
||||
2018/08/03, ENDOH takanao, djmchl@gmail.com
|
||||
2018/10/08, xsIceman, Andreas Skaar, andreas.skaar@gmail.com
|
||||
2018/10/18, edirgarcia, Edir García Lazo, edirgl@hotmail.com
|
||||
2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com
|
||||
2018/08/03, ENDOH takanao, djmchl@gmail.com
|
||||
|
@ -258,4 +259,5 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2020/09/06, ArthurSonzogni, Sonzogni Arthur, arthursonzogni@gmail.com
|
||||
2020/09/12, Clcanny, Charles Ruan, a837940593@gmail.com
|
||||
2020/09/15, rmcgregor1990, Robert McGregor, rmcgregor1990@gmail.com
|
||||
2020/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net
|
||||
2020/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net
|
||||
2020/10/08, Marti2203, Martin Mirchev, mirchevmartin2203@gmail.com
|
|
@ -1,6 +1,6 @@
|
|||
# C++
|
||||
|
||||
The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me//Antlr-,-C++-and-CMake-Wait-what.html).
|
||||
The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](https://beyondtheloop.dev/Antlr-cpp-cmake/).
|
||||
|
||||
## How to create a C++ lexer or parser?
|
||||
This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Antlr4.Runtime.Atn
|
|||
return false;
|
||||
}
|
||||
Antlr4.Runtime.Atn.SingletonPredictionContext other = (Antlr4.Runtime.Atn.SingletonPredictionContext)o;
|
||||
return returnState == other.returnState && parent.Equals(other.parent);
|
||||
return returnState == other.returnState && (parent != null && parent.Equals(other.parent));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -22,20 +22,20 @@ namespace Antlr4.Runtime
|
|||
#if !PORTABLE
|
||||
public class TraceListener : IParseTreeListener
|
||||
{
|
||||
private readonly TextWriter Output;
|
||||
|
||||
public TraceListener(TextWriter output) {
|
||||
Output = output;
|
||||
public TraceListener(TextWriter output,Parser enclosing) {
|
||||
_output = output;
|
||||
_enclosing = enclosing;
|
||||
}
|
||||
|
||||
public virtual void EnterEveryRule(ParserRuleContext ctx)
|
||||
{
|
||||
Output.WriteLine("enter " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text);
|
||||
_output.WriteLine("enter " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text);
|
||||
}
|
||||
|
||||
public virtual void ExitEveryRule(ParserRuleContext ctx)
|
||||
{
|
||||
Output.WriteLine("exit " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text);
|
||||
_output.WriteLine("exit " + this._enclosing.RuleNames[ctx.RuleIndex] + ", LT(1)=" + this._enclosing._input.LT(1).Text);
|
||||
}
|
||||
|
||||
public virtual void VisitErrorNode(IErrorNode node)
|
||||
|
@ -46,15 +46,17 @@ namespace Antlr4.Runtime
|
|||
{
|
||||
ParserRuleContext parent = (ParserRuleContext)((IRuleNode)node.Parent).RuleContext;
|
||||
IToken token = node.Symbol;
|
||||
Output.WriteLine("consume " + token + " rule " + this._enclosing.RuleNames[parent.RuleIndex]);
|
||||
_output.WriteLine("consume " + token + " rule " + this._enclosing.RuleNames[parent.RuleIndex]);
|
||||
}
|
||||
|
||||
internal TraceListener(Parser _enclosing)
|
||||
{
|
||||
this._enclosing = _enclosing;
|
||||
_output = Console.Out;
|
||||
}
|
||||
|
||||
private readonly Parser _enclosing;
|
||||
private readonly TextWriter _output;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue