dlvhex  2.5.0
src/HexGrammar.cpp
Go to the documentation of this file.
00001 /* dlvhex -- Answer-Set Programming with external interfaces.
00002  * Copyright (C) 2005-2007 Roman Schindlauer
00003  * Copyright (C) 2006-2015 Thomas Krennwallner
00004  * Copyright (C) 2009-2016 Peter Schüller
00005  * Copyright (C) 2011-2016 Christoph Redl
00006  * Copyright (C) 2015-2016 Tobias Kaminski
00007  * Copyright (C) 2015-2016 Antonius Weinzierl
00008  *
00009  * This file is part of dlvhex.
00010  *
00011  * dlvhex is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU Lesser General Public License as
00013  * published by the Free Software Foundation; either version 2.1 of
00014  * the License, or (at your option) any later version.
00015  *
00016  * dlvhex is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with dlvhex; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00036 #ifdef HAVE_CONFIG_H
00037 #include "config.h"
00038 #endif                           // HAVE_CONFIG_H
00039 
00040 // spirit parser node debugging
00041 //#define BOOST_SPIRIT_DEBUG
00042 // spirit parser node debugging for whitespace parser (comments and spaces)
00043 //#define BOOST_SPIRIT_DEBUG_WS
00044 
00045 #include "dlvhex2/PlatformDefinitions.h"
00046 #include "dlvhex2/HexGrammar.h"
00047 #include "dlvhex2/HexGrammar.tcc"
00048 
00049 DLVHEX_NAMESPACE_BEGIN
00050 
00051 // instantiate skip parser grammar
00052 template struct HexParserSkipperGrammar<HexParserIterator>;
00053 
00054 // instantiate HEX parser grammar base
00055 template struct HexGrammarBase<HexParserIterator, HexParserSkipper>;
00056 
00057 // instantiate HEX parser grammar
00058 template struct HexGrammar<HexParserIterator, HexParserSkipper>;
00059 
00060 // HEX grammar semantic action processor
00061 HexGrammarSemantics::HexGrammarSemantics(ProgramCtx& ctx):
00062 ctx(ctx)
00063 {
00064     mlpMode=0;
00065 }
00066 
00067 
00068 void HexGrammarSemantics::markExternalPropertyIfExternalBody(
00069 RegistryPtr registry, Rule& r)
00070 {
00071     Tuple eatoms;
00072     registry->getExternalAtomsInTuple(r.body, eatoms);
00073     if( !eatoms.empty() )
00074         r.kind |= ID::PROPERTY_RULE_EXTATOMS;
00075 }
00076 
00077 
00078 void HexGrammarSemantics::markModulePropertyIfModuleBody(
00079 RegistryPtr registry, Rule& r)
00080 {
00081     for(Tuple::const_iterator itt = r.body.begin(); itt != r.body.end(); ++itt) {
00082         if( itt->isModuleAtom() ) {
00083             r.kind |= ID::PROPERTY_RULE_MODATOMS;
00084             return;
00085         }
00086     }
00087 }
00088 
00089 
00090 DLVHEX_NAMESPACE_END
00091 
00092 // vim:expandtab:ts=4:sw=4:
00093 // mode: C++
00094 // End: