souffle  2.0.2-371-g6315b36
ParserDriver.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ParserDriver.h
12  *
13  * Defines the parser driver.
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "RelationTag.h"
20 #include "ast/Clause.h"
21 #include "ast/Component.h"
22 #include "ast/ComponentInit.h"
23 #include "ast/Directive.h"
24 #include "ast/FunctorDeclaration.h"
25 #include "ast/Pragma.h"
26 #include "ast/QualifiedName.h"
27 #include "ast/Relation.h"
28 #include "ast/SubsetType.h"
29 #include "ast/TranslationUnit.h"
30 #include "ast/Type.h"
31 #include "parser/SrcLocation.h"
32 #include "parser/parser.hh"
33 #include "reports/DebugReport.h"
34 #include <cstdio>
35 #include <memory>
36 #include <set>
37 #include <string>
38 #include <vector>
39 
40 namespace souffle {
41 
42 using yyscan_t = void*;
43 
44 struct scanner_data {
45  SrcLocation yylloc;
46 
47  /* Stack of parsed files */
48  std::string yyfilename;
49 };
50 
51 class ParserDriver {
52 public:
53  virtual ~ParserDriver() = default;
54 
56 
65 
69 
70  std::set<RelationTag> addReprTag(RelationTag tag, SrcLocation tagLoc, std::set<RelationTag> tags);
71  std::set<RelationTag> addDeprecatedTag(RelationTag tag, SrcLocation tagLoc, std::set<RelationTag> tags);
72  std::set<RelationTag> addTag(RelationTag tag, SrcLocation tagLoc, std::set<RelationTag> tags);
73  std::set<RelationTag> addTag(RelationTag tag, std::vector<RelationTag> incompatible, SrcLocation tagLoc,
74  std::set<RelationTag> tags);
75 
76  bool trace_scanning = false;
77 
79  const std::string& filename, FILE* in, ErrorReport& errorReport, DebugReport& debugReport);
81  const std::string& code, ErrorReport& errorReport, DebugReport& debugReport);
83  const std::string& filename, FILE* in, ErrorReport& errorReport, DebugReport& debugReport);
85  const std::string& code, ErrorReport& errorReport, DebugReport& debugReport);
86 
87  void warning(const SrcLocation& loc, const std::string& msg);
88  void error(const SrcLocation& loc, const std::string& msg);
89  void error(const std::string& msg);
90 };
91 
92 } // end of namespace souffle
93 
94 #define YY_DECL yy::parser::symbol_type yylex(souffle::ParserDriver& driver, yyscan_t yyscanner)
souffle::ParserDriver::parseTranslationUnit
static Own< ast::TranslationUnit > parseTranslationUnit(const std::string &filename, FILE *in, ErrorReport &errorReport, DebugReport &debugReport)
Definition: ParserDriver.cpp:84
souffle::ParserDriver::addReprTag
std::set< RelationTag > addReprTag(RelationTag tag, SrcLocation tagLoc, std::set< RelationTag > tags)
Definition: ParserDriver.cpp:212
souffle::ParserDriver::~ParserDriver
virtual ~ParserDriver()=default
TranslationUnit.h
DebugReport.h
souffle::ParserDriver::addPragma
void addPragma(Own< ast::Pragma > p)
Definition: ParserDriver.cpp:96
souffle::ParserDriver::trace_scanning
bool trace_scanning
Definition: ParserDriver.h:82
Directive.h
souffle::ParserDriver::addDirective
void addDirective(Own< ast::Directive > d)
Definition: ParserDriver.cpp:129
souffle::ParserDriver::addFunctorDeclaration
void addFunctorDeclaration(Own< ast::FunctorDeclaration > f)
Definition: ParserDriver.cpp:101
SrcLocation.h
souffle::ParserDriver::addRelation
void addRelation(Own< ast::Relation > r)
Definition: ParserDriver.cpp:116
Component.h
souffle::Own
std::unique_ptr< A > Own
Definition: ContainerUtil.h:42
souffle::scanner_data::yyfilename
std::string yyfilename
Definition: ParserDriver.h:54
souffle::ast::Relation
Defines a relation with a name, attributes, qualifiers, and internal representation.
Definition: Relation.h:49
souffle::ParserDriver::addDeprecatedTag
std::set< RelationTag > addDeprecatedTag(RelationTag tag, SrcLocation tagLoc, std::set< RelationTag > tags)
Definition: ParserDriver.cpp:204
ComponentInit.h
Relation.h
souffle::ParserDriver
Definition: ParserDriver.h:57
souffle::ParserDriver::addInstantiation
void addInstantiation(Own< ast::ComponentInit > ci)
Definition: ParserDriver.cpp:184
souffle::ParserDriver::addType
void addType(Own< ast::Type > type)
Definition: ParserDriver.cpp:161
RelationTag.h
souffle::DebugReport
Class representing a HTML report, consisting of a list of sections.
Definition: DebugReport.h:87
YY_DECL
#define YY_DECL
Definition: ParserDriver.h:94
souffle::RelationTag
RelationTag
Space of user-chosen tags that a relation can have.
Definition: RelationTag.h:31
souffle::ParserDriver::addClause
void addClause(Own< ast::Clause > c)
Definition: ParserDriver.cpp:176
Type.h
souffle::ParserDriver::translationUnit
Own< ast::TranslationUnit > translationUnit
Definition: ParserDriver.h:61
souffle::ParserDriver::mkDeprecatedSubType
Own< ast::SubsetType > mkDeprecatedSubType(ast::QualifiedName name, ast::QualifiedName attr, SrcLocation loc)
Definition: ParserDriver.cpp:232
Pragma.h
SubsetType.h
souffle::ParserDriver::addTag
std::set< RelationTag > addTag(RelationTag tag, SrcLocation tagLoc, std::set< RelationTag > tags)
Definition: ParserDriver.cpp:218
FunctorDeclaration.h
QualifiedName.h
souffle::ParserDriver::parse
Own< ast::TranslationUnit > parse(const std::string &filename, FILE *in, ErrorReport &errorReport, DebugReport &debugReport)
Definition: ParserDriver.cpp:50
souffle::SrcLocation
A class describing a range in an input file.
Definition: SrcLocation.h:32
souffle::ParserDriver::addIoFromDeprecatedTag
void addIoFromDeprecatedTag(ast::Relation &r)
Definition: ParserDriver.cpp:189
Clause.h
souffle::ParserDriver::error
void error(const SrcLocation &loc, const std::string &msg)
Definition: ParserDriver.cpp:243
souffle
Definition: AggregateOp.h:25
d
else d
Definition: htmlJsChartistMin.h:15
souffle::ParserDriver::addComponent
void addComponent(Own< ast::Component > c)
Definition: ParserDriver.cpp:180
souffle::scanner_data::yylloc
SrcLocation yylloc
Definition: ParserDriver.h:51
souffle::ast::QualifiedName
Qualified Name class defines fully/partially qualified names to identify objects in components.
Definition: QualifiedName.h:39
souffle::ErrorReport
Definition: ErrorReport.h:152
souffle::ParserDriver::warning
void warning(const SrcLocation &loc, const std::string &msg)
Definition: ParserDriver.cpp:240
souffle::yyscan_t
void * yyscan_t
Definition: ParserDriver.h:48
std::type
ElementType type
Definition: span.h:640
p
a horizontalBars(j=m=void 0===a.axisX.type?new c.AutoScaleAxis(c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})):a.axisX.type.call(c, c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})), l=n=void 0===a.axisY.type?new c.StepAxis(c.Axis.units.y, b.normalized.series, o,{ticks:k}):a.axisY.type.call(c, c.Axis.units.y, b.normalized.series, o, a.axisY)) var p
Definition: htmlJsChartistMin.h:15