org.antlr.v4.tool.templates.codegen.Cpp.Files.stg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
/*
* [The "BSD license"]
* Copyright (c) 2016, Mike Lischke
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
codeFileExtension() ::= ".cpp"
headerFileExtension() ::= ".h"
fileHeader(grammarFileName, ANTLRVersion, header) ::= <<
// Generated from by ANTLR
>>
LexerFileHeader(file, lexer, namedActions) ::= <<
#pragma once
#include "antlr4-runtime.h"
namespace {
} // namespace
>>
LexerFile(file, lexer, namedActions) ::= <<
#include ".h"
using namespace antlr4;
using namespace ;
>>
ParserFileHeader(file, parser, namedActions, contextSuperClass) ::= <<
#pragma once
#include "antlr4-runtime.h"
namespace {
} // namespace
>>
ParserFile(file, parser, namedActions, contextSuperClass) ::= <<
#include "Listener.h"
#include "Visitor.h"
#include ".h"
using namespace antlrcpp;
using namespace ;
>>
BaseListenerFileHeader(file, header, namedActions) ::= <<
#pragma once
#include "antlr4-runtime.h"
#include "Listener.h"
namespace {
/**
* This class provides an empty implementation of Listener,
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
class BaseListener : public Listener {
public:
(::Context * /*ctx*/) override { \}
virtual void exit(::Context * /*ctx*/) override { \}
}; separator="\n">
virtual void enterEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
virtual void exitEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
virtual void visitTerminal(antlr4::tree::TerminalNode * /*node*/) override { }
virtual void visitErrorNode(antlr4::tree::ErrorNode * /*node*/) override { }
private:
};
} // namespace
>>
BaseListenerFile(file, header, namedActions) ::= <<
#include "BaseListener.h"
using namespace ;
>>
ListenerFileHeader(file, header, namedActions) ::= <<
#pragma once
#include "antlr4-runtime.h"
#include ".h"
namespace {
/**
* This interface defines an abstract listener for a parse tree produced by .
*/
class Listener : public antlr4::tree::ParseTreeListener {
public:
(::Context *ctx) = 0;
virtual void exit(::Context *ctx) = 0;
}; separator = "\n">
private:
};
} // namespace
>>
ListenerFile(file, header, namedActions) ::= <<
#include "Listener.h"
using namespace ;
>>
BaseVisitorFileHeader(file, header, namedActions) ::= <<
#pragma once
#include "antlr4-runtime.h"
#include "Visitor.h"
namespace {
/**
* This class provides an empty implementation of Visitor, which can be
* extended to create a visitor which only needs to handle a subset of the available methods.
*/
class BaseVisitor : public Visitor {
public:
(::Context *ctx) override {
return visitChildren(ctx);
\}
}; separator="\n">
private:
};
} // namespace
>>
BaseVisitorFile(file, header, namedActions) ::= <<
#include "BaseVisitor.h"
using namespace ;
>>
VisitorFileHeader(file, header, namedActions) ::= <<
#pragma once
#include "antlr4-runtime.h"
#include ".h"
namespace {
/**
* This class defines an abstract visitor for a parse tree
* produced by .
*/
class Visitor : public antlr4::tree::AbstractParseTreeVisitor {
public:
/**
* Visit parse trees produced by .
*/
(::Context *context) = 0;
}; separator="\n">
private:
};
} // namespace
>>
VisitorFile(file, header, namedActions) ::= <<
#include "Visitor.h"
using namespace ;
>>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy