aboutsummaryrefslogtreecommitdiffstats
path: root/Scanner.h
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-01 06:25:42 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-01 06:25:42 +0800
commit21fdd84c09edd837fde1299c8e4f0b9545a8c1fa (patch)
treeee1f211fdb3582a4bb9ed124ca4d167b0460edc1 /Scanner.h
parenta59546473916fcccb2ddc444e7264a94c551c617 (diff)
downloaddexon-solidity-21fdd84c09edd837fde1299c8e4f0b9545a8c1fa.tar.gz
dexon-solidity-21fdd84c09edd837fde1299c8e4f0b9545a8c1fa.tar.zst
dexon-solidity-21fdd84c09edd837fde1299c8e4f0b9545a8c1fa.zip
Moving LiteralScope to Scanner.cpp
Diffstat (limited to 'Scanner.h')
-rw-r--r--Scanner.h42
1 files changed, 1 insertions, 41 deletions
diff --git a/Scanner.h b/Scanner.h
index e9262ba3..49ac3651 100644
--- a/Scanner.h
+++ b/Scanner.h
@@ -96,45 +96,9 @@ private:
class Scanner
{
+ friend class LiteralScope;
public:
- enum LiteralType {
- LITERAL_TYPE_STRING,
- LITERAL_TYPE_NUMBER, // not really different from string type in behaviour
- LITERAL_TYPE_COMMENT
- };
- /// Scoped helper for literal recording. Automatically drops the literal
- /// if aborting the scanning before it's complete.
- class LiteralScope
- {
- public:
- explicit LiteralScope(Scanner* _self, enum LiteralType _type): m_type(_type)
- , m_scanner(_self)
- , m_complete(false)
- {
- if (_type == LITERAL_TYPE_COMMENT)
- m_scanner->startNewCommentLiteral();
- else
- m_scanner->startNewLiteral();
- }
- ~LiteralScope()
- {
- if (!m_complete)
- {
- if (m_type == LITERAL_TYPE_COMMENT)
- m_scanner->dropCommentLiteral();
- else
- m_scanner->dropLiteral();
- }
- }
- void complete() { m_complete = true; }
-
- private:
- enum LiteralType m_type;
- Scanner* m_scanner;
- bool m_complete;
- };
-
Scanner() { reset(CharStream()); }
explicit Scanner(CharStream const& _source) { reset(_source); }
@@ -194,12 +158,8 @@ private:
///@{
///@name Literal buffer support
- inline void startNewLiteral() { m_nextToken.literal.clear(); }
- inline void startNewCommentLiteral() { m_nextSkippedComment.literal.clear(); }
inline void addLiteralChar(char c) { m_nextToken.literal.push_back(c); }
inline void addCommentLiteralChar(char c) { m_nextSkippedComment.literal.push_back(c); }
- inline void dropLiteral() { m_nextToken.literal.clear(); }
- inline void dropCommentLiteral() { m_nextSkippedComment.literal.clear(); }
inline void addLiteralCharAndAdvance() { addLiteralChar(m_char); advance(); }
///@}