Code Monkey home page Code Monkey logo

antlr4-cpp's People

Contributors

gitter-badger avatar sharwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

antlr4-cpp's Issues

Unit Test expecting 57, 123; code review

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;

Apply const to generated parser code

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.

About antlrcpp::Any derived.

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?

Question, possible feature request

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?

XCode Support

I'm just wondering two things:

  • When will be possible to use ANTR4 in real project? How close is it to be finished?
  • Will there be XCode support to build the project?

error: use of undeclared identifier 'self'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.