aboutsummaryrefslogtreecommitdiffstats
path: root/source/Symbol/PostfixExpression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/PostfixExpression.cpp')
-rw-r--r--source/Symbol/PostfixExpression.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/Symbol/PostfixExpression.cpp b/source/Symbol/PostfixExpression.cpp
index 148653561a4e..8ecd571ed929 100644
--- a/source/Symbol/PostfixExpression.cpp
+++ b/source/Symbol/PostfixExpression.cpp
@@ -41,7 +41,8 @@ GetUnaryOpType(llvm::StringRef token) {
return llvm::None;
}
-Node *postfix::Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc) {
+Node *postfix::ParseOneExpression(llvm::StringRef expr,
+ llvm::BumpPtrAllocator &alloc) {
llvm::SmallVector<Node *, 4> stack;
llvm::StringRef token;
@@ -83,6 +84,26 @@ Node *postfix::Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc) {
return stack.back();
}
+std::vector<std::pair<llvm::StringRef, Node *>>
+postfix::ParseFPOProgram(llvm::StringRef prog, llvm::BumpPtrAllocator &alloc) {
+ llvm::SmallVector<llvm::StringRef, 4> exprs;
+ prog.split(exprs, '=');
+ if (exprs.empty() || !exprs.back().trim().empty())
+ return {};
+ exprs.pop_back();
+
+ std::vector<std::pair<llvm::StringRef, Node *>> result;
+ for (llvm::StringRef expr : exprs) {
+ llvm::StringRef lhs;
+ std::tie(lhs, expr) = getToken(expr);
+ Node *rhs = ParseOneExpression(expr, alloc);
+ if (!rhs)
+ return {};
+ result.emplace_back(lhs, rhs);
+ }
+ return result;
+}
+
namespace {
class SymbolResolver : public Visitor<bool> {
public: