antlr / antlr4-cpp Goto Github PK
View Code? Open in Web Editor NEWC++ target for ANTLR 4, including templates and runtime
License: Other
C++ target for ANTLR 4, including templates and runtime
License: Other
Hello,
Inspiring on C ++ test for my unit tests in C, I noticed an error in the expecting result. Maybe the +1
has no effect?
In https://github.com/antlr/antlr4-cpp/blob/master/antlr4cpp/antlr/test/test_interval_set.cpp
void test_mixed_ranges_and_elements()
{
interval_set s;
s.insert(1);
s.insert(std::make_pair(L'a',L'z'+1));
s.insert(std::make_pair(L'0',L'9'+1));
std::wstring expecting = L"{1, 48..57, 97..122}";
}
by comparison with Java implementation
IntervalSet interval_set = new IntervalSet();
interval_set.add(1);
interval_set.add('a', 'z'+1);
interval_set.add('0', '9'+1);
String str = interval_set.toString();
String expecting = "{1, 48..58, 97..123}";
PS:
C ++ operator overloading is friendly
interval_set s;
s << 1;// s+1 is ambigus
s << interval('a', 'z'+1);
s &= interval('0', '9'+1);
s |= interval('0', '9'+1);
std::cout << s << std::endl;
Hi,
I'm using references to the generated parser contexts in my AST implementation. I find that I have a tendency to want to return const pointers from getter functions.
class AstExpression
{
public:
const MyParser::ExpressionContext* getContext() const;
};
However calling any function on that return value to further navigate the parse-tree complains about the const
because these functions are not declared as const (not changing the instance).
Would it be possible to generate const
aware code?
This would make it more correct (and strict).
Another one to consider is noexcept
.
Also seen virtual
and override
being used together. MSVC 'complains' that only one is needed. Not sure if other compilers feel the same.
Hi,
There are the following codes:
class A {};
class B : public A {};
B *b = new B;
antlrcpp::Any any = b;
bool is = any.is<A*>();
Variable ìs' always `false'. How do I solve this type of derivation problem?
Is this project stalled indefinitely or is there an optimistic future ahead?
For data members of rule contexts, is there any particular reason that specifying some rule context class name as the type for a parameter for that some other rule tries to accept the argument only by value instead of by address? Would changing this so that if a type name used for a parameter refers to a rule context name in the grammar, then that parameter is actually just a pointer and not the concrete value cause more issues?
I'm just wondering two things:
Hello, I have multiple error when compiling the generated parser and lexer.
ANTLR version: 4.13.0
Os: Macos
Command used: antlr -Dlanguage=Cpp -o ${CMAKE_CURRENT_SOURCE_DIR}/src/LythonCompiler/Parser/ANTLR/ ${CMAKE_CURRENT_SOURCE_DIR}/src/LythonCompiler/Parser/ANTLR/Python3Parser.g4
the error:
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19168:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("case"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"case\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19224:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("_"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"_\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19280:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("type"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"type\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19329:20: error: use of undeclared identifier 'self'
case 1: return self.isnotEqualCurrentTokenText("_");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19419:21: error: use of undeclared identifier 'self'
case 10: return self.isEqualCurrentTokenText("match");
^
/Users//./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19429:21: error: use of undeclared identifier 'self'
case 11: return self.isEqualCurrentTokenText("case");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19439:21: error: use of undeclared identifier 'self'
case 12: return self.isEqualCurrentTokenText("_");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19449:21: error: use of undeclared identifier 'self'
case 13: return self.isEqualCurrentTokenText("type");
the grammar file used is located here: https://github.com/antlr/grammars-v4/tree/master/python/python3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.