summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-24 17:02:39 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-24 17:02:39 +0000
commit8f96c404824edf2013c4377ee041e0800283307b (patch)
tree2908118f5fa5b690013ab945ef02c2ec19b7611d /complex.c
parent0d7d3a80dd2e64951297b3122d5055fc1ff40091 (diff)
merge revision(s) 39677,39695: [Backport #8068]
* complex.c: described syntax of string form. * rational.c: ditto. * complex.c: edited rdoc. * rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@39918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/complex.c b/complex.c
index edbe2965f0..f6f63f6ebd 100644
--- a/complex.c
+++ b/complex.c
@@ -483,6 +483,28 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y)
*
* Complex(1, 2) #=> (1+2i)
* Complex('1+2i') #=> (1+2i)
+ *
+ * Syntax of string form:
+ *
+ * string form = extra spaces , complex , extra spaces ;
+ * 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" ;
+ * extra spaces = ? \s* ? ;
+ *
+ * See String#to_c.
*/
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
@@ -1825,6 +1847,8 @@ string_to_c_strict(VALUE self)
* '-0.0-0.0i'.to_c #=> (-0.0-0.0i)
* '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i)
* 'ruby'.to_c #=> (0+0i)
+ *
+ * See Kernel.Complex.
*/
static VALUE
string_to_c(VALUE self)