OpenWalnut  1.4.0
Classes | Typedefs | Functions
WStructuredTextParser Namespace Reference

This namespace contains the WStructuredTextParser data types and the parser. More...

Classes

struct  KeyValueType
 KeyValueType - a tuple containing name and value. More...
 
struct  ObjectType
 An object is always a name and contains several further nodes. More...
 

Typedefs

typedef std::string KeyType
 we use these quite often, so define some short alias for them: More...
 
typedef std::string ValueType
 The type used for values. More...
 
typedef std::string CommentType
 The type used for comments. More...
 
typedef boost::variant< boost::recursive_wrapper< ObjectType >, KeyValueType, CommentTypeMemberType
 A node inside the AST is either another object or a key-value pair. More...
 
typedef std::vector< MemberTypeFileType
 An object representing all objects and comments on file level. More...
 

Functions

FileType parseFromString (std::string input)
 Parse the given input and return the syntax tree. More...
 
FileType parseFromFile (boost::filesystem::path path)
 Parse the given input and return the syntax tree. More...
 

Detailed Description

This namespace contains the WStructuredTextParser data types and the parser.

It builds up the abstract syntax tree (AST) for the given input which later can be traversed.

Typedef Documentation

The type used for comments.

Definition at line 107 of file WStructuredTextParser.h.

An object representing all objects and comments on file level.

Definition at line 159 of file WStructuredTextParser.h.

typedef std::string WStructuredTextParser::KeyType

we use these quite often, so define some short alias for them:

we use these quite often, so define some short alias for them: we use these quite often, so define some short alias for them: we use these quite often, so define some short alias for them: we use these quite often, so define some short alias for them: The type used for keys

Definition at line 97 of file WStructuredTextParser.h.

typedef boost::variant< boost::recursive_wrapper< ObjectType >, KeyValueType, CommentType > WStructuredTextParser::MemberType

A node inside the AST is either another object or a key-value pair.

Definition at line 138 of file WStructuredTextParser.h.

typedef std::string WStructuredTextParser::ValueType

The type used for values.

Definition at line 102 of file WStructuredTextParser.h.

Function Documentation

FileType WStructuredTextParser::parseFromFile ( boost::filesystem::path  path)

Parse the given input and return the syntax tree.

Throws an exception WParseError on error.

Parameters
paththe file to parse
Returns
the syntax tree in plain format. You should use WStructuredValueTree to use this.
Exceptions
WParseErroron parse error
WFileNotFOundin case the specified file could not be opened

Definition at line 216 of file WStructuredTextParser.cpp.

References parseFromFile().

Referenced by parseFromFile(), and WStructuredTextParserTest::testParseFromFile().

FileType WStructuredTextParser::parseFromString ( std::string  input)

Parse the given input and return the syntax tree.

Throws an exception WParseError on error.

Parameters
inputthe input to parse.
Returns
the syntax tree in plain format. You should use WStructuredValueTree to use this.
Exceptions
WParseErroron parse error

Definition at line 195 of file WStructuredTextParser.cpp.

References parseFromString().

Referenced by parseFromString().