• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/RocsCore

  • sources
  • kde-4.12
  • kdeedu
  • rocs
  • RocsCore
  • LoadSave
  • Plugins
  • gmlFileFormat
GmlGrammar.h
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2010 Wagner Reck <wagner.reck@gmail.com>
4  Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*
21  * GraphViz dot Graph parsing grammar implemented with boost Spirit
22  */
23 
24 #ifndef GML_GRAMMAR_H
25 #define GML_GRAMMAR_H
26 
27 #include <boost/config/warning_disable.hpp>
28 #include <boost/spirit/include/qi.hpp>
29 #include <boost/spirit/include/phoenix_operator.hpp>
30 
31 #include <iostream>
32 #include <string>
33 
34 class Document;
35 class QString;
36 
37 namespace GmlParser
38 {
39 namespace qi = boost::spirit::qi;
40 namespace ascii = boost::spirit::ascii;
41 
42 
43 void gotKey(const std::string &key);
44 
45 void gotValue(const std::string &Value);
46 
47 void beginList();
48 
49 void endList();
50 
51 void t();
52 void t1();
53 
54 bool parse(const QString& content, Document* doc);
55 
56 template <typename Iterator>
57 struct roman : boost::spirit::qi::grammar<Iterator, unsigned()> {
58  roman() : roman::base_type(start) {
59  using qi::eps;
60  using qi::double_;
61  using qi::lexeme;
62  using qi::_val;
63  using ascii::char_;
64  using qi::_1;
65 
66  start = List;
67  List = -KeyValue >> *(+WhiteSpace >> KeyValue) >> *WhiteSpace;
68  KeyValue = *(WhiteSpace) >> Key[&gotKey] >> +WhiteSpace >> Value[&gotValue] ;
69  Key = (char_("a-zA-Z")[_val += _1] >> *char_("a-zA-Z0-9_")[_val += _1]);
70  Value = -Sign[_val += _1] >> +char_("0-9")[_val += _1] >> -((char_('.')[_val += _1] >> +char_("0-9")[_val += _1]))
71  | String[_val = _1]
72  | char_('[')[beginList] >> *WhiteSpace >> List >> *WhiteSpace >> char_(']')[endList] ;
73  String = lexeme[char_('"') >> *((char_ - '"') | char_('/'))[_val += _1] >> char_('"')];
74  Sign = (char_('+') | char_('-'))[_val += _1];
75  WhiteSpace = ascii::space;
76 }
77 
78 boost::spirit::qi::rule<Iterator, unsigned()> start;
79 boost::spirit::qi::rule<Iterator> List, KeyValue ;
80 boost::spirit::qi::rule<Iterator, std::string()> Key, Value, String, Sign;
81 boost::spirit::qi::rule<Iterator> WhiteSpace;
82 };
83 }
84 
85 #endif
GmlParser::gotValue
void gotValue(const std::string &Value)
Definition: GmlGrammar.cpp:73
GmlParser::roman::Sign
boost::spirit::qi::rule< Iterator, std::string()> Sign
Definition: GmlGrammar.h:80
GmlParser::roman::KeyValue
boost::spirit::qi::rule< Iterator > KeyValue
Definition: GmlGrammar.h:79
GmlParser::roman::Value
boost::spirit::qi::rule< Iterator, std::string()> Value
Definition: GmlGrammar.h:80
GmlParser::parse
bool parse(const QString &content, Document *doc)
Definition: GmlGrammar.cpp:105
GmlParser::roman::String
boost::spirit::qi::rule< Iterator, std::string()> String
Definition: GmlGrammar.h:80
GmlParser::beginList
void beginList()
Definition: GmlGrammar.cpp:42
GmlParser::t1
void t1(const std::string &key)
Definition: GmlGrammar.cpp:100
GmlParser::gotKey
void gotKey(const std::string &key)
Definition: GmlGrammar.cpp:52
GmlParser::roman::List
boost::spirit::qi::rule< Iterator > List
Definition: GmlGrammar.h:79
GmlParser::endList
void endList()
Definition: GmlGrammar.cpp:47
Document
Definition: Document.h:41
GmlParser::roman::start
boost::spirit::qi::rule< Iterator, unsigned()> start
Definition: GmlGrammar.h:78
GmlParser::roman::WhiteSpace
boost::spirit::qi::rule< Iterator > WhiteSpace
Definition: GmlGrammar.h:81
GmlParser::t
void t()
Definition: GmlGrammar.cpp:96
GmlParser::roman::roman
roman()
Definition: GmlGrammar.h:58
GmlParser::roman
Definition: GmlGrammar.h:57
GmlParser::roman::Key
boost::spirit::qi::rule< Iterator, std::string()> Key
Definition: GmlGrammar.h:80
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/RocsCore

Skip menu "rocs/RocsCore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal