瀏覽代碼

Create stateful_dice mainprog... currently a copy of simple dice

Sam Jaffe 7 年之前
父節點
當前提交
5b898a0844
共有 2 個文件被更改,包括 138 次插入0 次删除
  1. 108 0
      dice-roll.xcodeproj/project.pbxproj
  2. 30 0
      stateful_dice/main.cxx

+ 108 - 0
dice-roll.xcodeproj/project.pbxproj

@@ -18,6 +18,9 @@
 		CD38F53921C922E2007A732C /* roll_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD38F53821C922E2007A732C /* roll_test.cxx */; };
 		CD38F53B21C928B4007A732C /* exception_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD38F53A21C928B4007A732C /* exception_test.cxx */; };
 		CD38F54F21C945C2007A732C /* terminal_helper.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD38F54E21C945C2007A732C /* terminal_helper.cxx */; };
+		CD38F55721C9482A007A732C /* main.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD38F55621C9482A007A732C /* main.cxx */; };
+		CD38F56221C94872007A732C /* terminal_helper.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD38F54E21C945C2007A732C /* terminal_helper.cxx */; };
+		CD38F56521C94A00007A732C /* libdice.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD38F50921C83912007A732C /* libdice.dylib */; };
 		CDED6A2721B2F28A00AB91D0 /* main.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CDED6A2621B2F28A00AB91D0 /* main.cxx */; };
 /* End PBXBuildFile section */
 
@@ -71,9 +74,25 @@
 			remoteGlobalIDString = 05818F851A685AEA0072A469;
 			remoteInfo = GoogleMock;
 		};
+		CD38F56321C949FB007A732C /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CDED6A1B21B2F28A00AB91D0 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = CD38F50821C83912007A732C;
+			remoteInfo = dice;
+		};
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXCopyFilesBuildPhase section */
+		CD38F55221C9482A007A732C /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
 		CDED6A2121B2F28A00AB91D0 /* CopyFiles */ = {
 			isa = PBXCopyFilesBuildPhase;
 			buildActionMask = 2147483647;
@@ -96,6 +115,8 @@
 		CD38F53A21C928B4007A732C /* exception_test.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = exception_test.cxx; sourceTree = "<group>"; };
 		CD38F54D21C945C2007A732C /* terminal_helper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = terminal_helper.h; sourceTree = "<group>"; };
 		CD38F54E21C945C2007A732C /* terminal_helper.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = terminal_helper.cxx; sourceTree = "<group>"; };
+		CD38F55421C9482A007A732C /* stateful_dice */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = stateful_dice; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD38F55621C9482A007A732C /* main.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cxx; sourceTree = "<group>"; };
 		CD8F1ABC21B31E9E00CBB3CA /* roll.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = roll.h; sourceTree = "<group>"; };
 		CD8F1ABD21B31E9E00CBB3CA /* roll.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = roll.cxx; sourceTree = "<group>"; };
 		CDED6A2321B2F28A00AB91D0 /* simple_dice */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = simple_dice; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -125,6 +146,14 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		CD38F55121C9482A007A732C /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD38F56521C94A00007A732C /* libdice.dylib in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		CDED6A2021B2F28A00AB91D0 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -155,6 +184,22 @@
 			path = "dice-td";
 			sourceTree = "<group>";
 		};
+		CD38F55521C9482A007A732C /* stateful_dice */ = {
+			isa = PBXGroup;
+			children = (
+				CD38F55621C9482A007A732C /* main.cxx */,
+			);
+			path = stateful_dice;
+			sourceTree = "<group>";
+		};
+		CD38F55E21C9485F007A732C /* simple_dice */ = {
+			isa = PBXGroup;
+			children = (
+				CDED6A2621B2F28A00AB91D0 /* main.cxx */,
+			);
+			path = simple_dice;
+			sourceTree = "<group>";
+		};
 		CDED6A1A21B2F28A00AB91D0 = {
 			isa = PBXGroup;
 			children = (
@@ -164,6 +209,7 @@
 				CDED6A2521B2F28A00AB91D0 /* src */,
 				CD38F52721C87771007A732C /* dice-td */,
 				CD38F55E21C9485F007A732C /* simple_dice */,
+				CD38F55521C9482A007A732C /* stateful_dice */,
 				CDED6A2421B2F28A00AB91D0 /* Products */,
 				CDED6A5F21B2F89900AB91D0 /* Frameworks */,
 			);
@@ -175,6 +221,7 @@
 				CDED6A2321B2F28A00AB91D0 /* simple_dice */,
 				CD38F50921C83912007A732C /* libdice.dylib */,
 				CD38F52621C87771007A732C /* dice-td.xctest */,
+				CD38F55421C9482A007A732C /* stateful_dice */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -269,6 +316,24 @@
 			productReference = CD38F52621C87771007A732C /* dice-td.xctest */;
 			productType = "com.apple.product-type.bundle.unit-test";
 		};
+		CD38F55321C9482A007A732C /* stateful_dice */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = CD38F55821C9482A007A732C /* Build configuration list for PBXNativeTarget "stateful_dice" */;
+			buildPhases = (
+				CD38F55021C9482A007A732C /* Sources */,
+				CD38F55121C9482A007A732C /* Frameworks */,
+				CD38F55221C9482A007A732C /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				CD38F56421C949FB007A732C /* PBXTargetDependency */,
+			);
+			name = stateful_dice;
+			productName = stateful_dice;
+			productReference = CD38F55421C9482A007A732C /* stateful_dice */;
+			productType = "com.apple.product-type.tool";
+		};
 		CDED6A2221B2F28A00AB91D0 /* simple_dice */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = CDED6A2A21B2F28A00AB91D0 /* Build configuration list for PBXNativeTarget "simple_dice" */;
@@ -302,6 +367,9 @@
 					CD38F52521C87771007A732C = {
 						CreatedOnToolsVersion = 10.1;
 					};
+					CD38F55321C9482A007A732C = {
+						CreatedOnToolsVersion = 10.1;
+					};
 					CDED6A2221B2F28A00AB91D0 = {
 						CreatedOnToolsVersion = 10.1;
 					};
@@ -328,6 +396,7 @@
 				CDED6A2221B2F28A00AB91D0 /* simple_dice */,
 				CD38F50821C83912007A732C /* dice */,
 				CD38F52521C87771007A732C /* dice-td */,
+				CD38F55321C9482A007A732C /* stateful_dice */,
 			);
 		};
 /* End PBXProject section */
@@ -394,6 +463,15 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		CD38F55021C9482A007A732C /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD38F55721C9482A007A732C /* main.cxx in Sources */,
+				CD38F56221C94872007A732C /* terminal_helper.cxx in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		CDED6A1F21B2F28A00AB91D0 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -421,6 +499,11 @@
 			name = GoogleMock;
 			targetProxy = CD38F53121C87783007A732C /* PBXContainerItemProxy */;
 		};
+		CD38F56421C949FB007A732C /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = CD38F50821C83912007A732C /* dice */;
+			targetProxy = CD38F56321C949FB007A732C /* PBXContainerItemProxy */;
+		};
 /* End PBXTargetDependency section */
 
 /* Begin XCBuildConfiguration section */
@@ -480,6 +563,22 @@
 			};
 			name = Release;
 		};
+		CD38F55921C9482A007A732C /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		CD38F55A21C9482A007A732C /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
 		CDED6A2821B2F28A00AB91D0 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -644,6 +743,15 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
+		CD38F55821C9482A007A732C /* Build configuration list for PBXNativeTarget "stateful_dice" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD38F55921C9482A007A732C /* Debug */,
+				CD38F55A21C9482A007A732C /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		CDED6A1E21B2F28A00AB91D0 /* Build configuration list for PBXProject "dice-roll" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (

+ 30 - 0
stateful_dice/main.cxx

@@ -0,0 +1,30 @@
+//
+//  main.cpp
+//  stateful_dice
+//
+//  Created by Sam Jaffe on 12/18/18.
+//  Copyright © 2018 Sam Jaffe. All rights reserved.
+//
+
+#include "exception.h"
+#include "terminal_helper.h"
+
+#include <iostream>
+
+void eval(std::string const & str) {
+  try {
+    terminal::process_dice_string(str);
+  } catch (dice::unexpected_token const & ut) {
+    terminal::print_error_message(str, ut);
+  }
+}
+
+int main(int, const char **) {
+  std::string line;
+  std::cout << "> ";
+  while (std::getline(std::cin, line)) {
+    eval(line);
+    std::cout << "> ";
+  }
+  return 0;
+}