summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 00:18:52 (GMT)
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 00:18:52 (GMT)
commitec9eabc6c2df764c2c51e72e23bb7512bb77d965 (patch)
treeb1c5fd04d75d47732d1fcbd0702080d65d32fbbf
parentb3265c0ed6d7a2db76c172aef128445902c36c63 (diff)
* complex.c: described syntax of string form.
* rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--complex.c18
-rw-r--r--rational.c12
3 files changed, 35 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 99bc01a..fbdcb2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Mar 10 09:12:51 2013 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c: described syntax of string form.
+ * rational.c: ditto.
+
Sat Mar 9 11:58:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (w_extended): check for prepended object.
diff --git a/complex.c b/complex.c
index edbe296..5445b49 100644
--- a/complex.c
+++ b/complex.c
@@ -483,6 +483,24 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y)
*
* Complex(1, 2) #=> (1+2i)
* Complex('1+2i') #=> (1+2i)
+ *
+ * Syntax of string form:
+ *
+ * complex = real part | [ sign ] , imaginary part
+ * | real part , sign , imaginary part
+ * | rational , "@" , rational ;
+ * real part = rational ;
+ * imaginary part = imaginary unit | unsigned rational , imaginary unit ;
+ * rational = [ sign ] , unsigned rational ;
+ * unsigned rational = numerator | numerator , "/" , denominator ;
+ * numerator = integer part | fractional part | integer part , fractional part ;
+ * denominator = digits ;
+ * integer part = digits ;
+ * fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
+ * imaginary unit = "i" | "I" | "j" | "J" ;
+ * sign = "-" | "+" ;
+ * digits = digit , [ { digit | "_" , digit } ] ;
+ * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
*/
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
diff --git a/rational.c b/rational.c
index a78b320..e5992ed 100644
--- a/rational.c
+++ b/rational.c
@@ -571,6 +571,18 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y)
*
* Rational(1, 2) #=> (1/2)
* Rational('1/2') #=> (1/2)
+ *
+ * Syntax of string form:
+ *
+ * rational = [ sign ] , unsigned rational ;
+ * unsigned rational = numerator | numerator , "/" , denominator ;
+ * numerator = integer part | fractional part | integer part , fractional part ;
+ * denominator = digits ;
+ * integer part = digits ;
+ * fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
+ * sign = "-" | "+" ;
+ * digits = digit , [ { digit | "_" , digit } ] ;
+ * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
*/
static VALUE
nurat_f_rational(int argc, VALUE *argv, VALUE klass)