From 5aed7c46cff192311a208dc5e9cf7f81a40771a8 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 31 Mar 2015 23:49:44 +0200 Subject: Implement TokenStack::lookup method used to lookup the SyntaxDescriptors associated with a certain token. --- src/core/parser/stack/TokenStack.hpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/core/parser/stack/TokenStack.hpp') diff --git a/src/core/parser/stack/TokenStack.hpp b/src/core/parser/stack/TokenStack.hpp index 32f181a..d5deafe 100644 --- a/src/core/parser/stack/TokenStack.hpp +++ b/src/core/parser/stack/TokenStack.hpp @@ -37,6 +37,34 @@ namespace ousia { namespace parser_stack { +/** + * Structure describing a token once it has been found in the text. Contains + * lists pointing at the corresponding SyntaxDescriptors for the open, close and + * shortForm token types. + */ +struct TokenDescriptor { + /** + * Vector containing the SyntaxDescriptors in which the token occurs as + * "close" token. The Token is first tried to be processed as a "close" + * token. + */ + std::vector close; + + /** + * Vector containing the SyntaxDescriptors in which the token occurs as + * "shortForm" token. Creating a "shortForm" of the referenced ontology + * descriptor is tried next. + */ + std::vector shortForm; + + /** + * Vector containing the SyntaxDescriptors in which the token occurs as + * "open" token. The possibility of using the token in the "open" mode is + * tried in the last step. + */ + std::vector open; +}; + /** * The TokenStack class is used by the Stack class to collect all currently * enabled user defined tokens. @@ -65,6 +93,14 @@ public: */ void popTokens(); + /** + * Returns the TokenDescriptor for the given token. + * + * @param token is the token for which the different forms should be looked + * up. + */ + TokenDescriptor lookup(TokenId token) const; + /** * Returns a set containing all currently enabled tokens. The set of enabled * tokens are those tokens that were pushed last onto the stack. This set -- cgit v1.2.3