aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/ObjectParser.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-28 18:33:29 +0800
committerGitHub <noreply@github.com>2018-11-28 18:33:29 +0800
commit7cbf04686442b44b41d7b24800edb8444db31092 (patch)
tree01df06aea5ea6845f8bf54f93e6efef335c06b72 /libyul/ObjectParser.h
parentbc7cb301e3d71756c8fbefe888aca53433302117 (diff)
parent69dcf1a5f78ce6caf1c78012e599d7a1f08a6877 (diff)
downloaddexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar.gz
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar.bz2
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar.lz
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar.xz
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.tar.zst
dexon-solidity-7cbf04686442b44b41d7b24800edb8444db31092.zip
Merge pull request #5358 from ethereum/yulObjects
[Yul] Yul objects parser
Diffstat (limited to 'libyul/ObjectParser.h')
-rw-r--r--libyul/ObjectParser.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/libyul/ObjectParser.h b/libyul/ObjectParser.h
new file mode 100644
index 00000000..1d88a119
--- /dev/null
+++ b/libyul/ObjectParser.h
@@ -0,0 +1,72 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * Parser for Yul code and data object container.
+ */
+
+#pragma once
+
+#include <libyul/YulString.h>
+#include <libyul/Object.h>
+
+#include <liblangutil/ErrorReporter.h>
+#include <liblangutil/ParserBase.h>
+
+#include <libdevcore/Common.h>
+
+#include <memory>
+
+namespace langutil
+{
+class Scanner;
+}
+
+namespace yul
+{
+
+/**
+ * Yul object parser. Invokes the inline assembly parser.
+ */
+class ObjectParser: public langutil::ParserBase
+{
+public:
+ explicit ObjectParser(
+ langutil::ErrorReporter& _errorReporter,
+ yul::AsmFlavour _flavour = yul::AsmFlavour::Loose
+ ):
+ ParserBase(_errorReporter), m_flavour(_flavour) {}
+
+ /// Parses a Yul object.
+ /// Falls back to code-only parsing if the source starts with `{`.
+ /// @param _reuseScanner if true, do check for end of input after the last `}`.
+ /// @returns an empty shared pointer on error.
+ std::shared_ptr<Object> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner);
+
+private:
+ std::shared_ptr<Object> parseObject(Object* _containingObject = nullptr);
+ std::shared_ptr<Block> parseCode();
+ std::shared_ptr<Block> parseBlock();
+ void parseData(Object& _containingObject);
+
+ /// Tries to parse a name that is non-empty and unique inside the containing object.
+ YulString parseUniqueName(Object const* _containingObject);
+ void addNamedSubObject(Object& _container, YulString _name, std::shared_ptr<ObjectNode> _subObject);
+
+ yul::AsmFlavour m_flavour;
+};
+
+}