瀏覽代碼

Add schema info for parser.

Sam Jaffe 4 年之前
父節點
當前提交
a4fd39e75e
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      include/dice-roll/parser.h

+ 20 - 0
include/dice-roll/parser.h

@@ -14,6 +14,26 @@
 
 namespace dice {
 
+/*
+ * A parser that translates a stream of text input into a dice object. The
+ * string matches the following schema-rule:
+ *
+ * dice-string:
+ *   dice-expression
+ *   positive-integer { dice-expression }
+ *
+ * positive-integer: Any integer number >= 0
+ *
+ * dice-expression:
+ *   die-expression
+ *   die-expression + dice-expression
+ *   die-expression - dice-expression
+ *
+ * die-expression:
+ *   integer
+ *   positive-integer 'd' positive-integer
+ *   positive-integer 'D' positive-integer
+ */
 class parser {
 private:
   std::istream & is_;