From 38df1a90cc68d132306c9484ed57faa0be656b0e Mon Sep 17 00:00:00 2001 From: why Date: Fri, 30 May 2003 23:09:54 +0000 Subject: [PATCH] * ext/syck/rubyext.c (rb_syck_mktime): seconds calculated wrong. * ext/syck/gram.c: flexibility to anchors and transfer methods on collections. * ext/syck/token.c: hex escapes. * lib/yaml/basenode.rb: YamlNode references changed to YAML::BaseNode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +- ext/syck/gram.c | 335 ++++++++++++++++++++++++------------------- ext/syck/rubyext.c | 17 ++- ext/syck/token.c | 332 +++++++++++++++++++++++++----------------- lib/yaml/basenode.rb | 4 +- 5 files changed, 418 insertions(+), 283 deletions(-) diff --git a/ChangeLog b/ChangeLog index 250ddaacb5..3d328f1254 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri May 30 23:18:01 2003 why the lucky stiff + + * ext/syck/rubyext.c (rb_syck_mktime): seconds calculated wrong. + + * ext/syck/gram.c: flexibility to anchors and transfer methods on + collections. + + * ext/syck/token.c: hex escapes. + + * lib/yaml/basenode.rb: YamlNode references changed to YAML::BaseNode. + Fri May 30 22:28:04 2003 Nobuyoshi Nakada * numeric.c (rb_num2uint, rb_fix2int): new function to convert @@ -7,7 +18,7 @@ Fri May 30 22:28:04 2003 Nobuyoshi Nakada Fri May 30 15:01:05 2003 why the lucky stiff - * ext/syck/token.c: preserve any indentation passed an explicit + * ext/syck/token.c: preserve any indentation past an explicit indentation. Fri May 30 14:55:44 2003 Nobuyoshi Nakada diff --git a/ext/syck/gram.c b/ext/syck/gram.c index 898413cb1a..03f3161666 100644 --- a/ext/syck/gram.c +++ b/ext/syck/gram.c @@ -229,16 +229,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 34 -#define YYLAST 217 +#define YYLAST 284 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 23 +#define YYNNTS 24 /* YYNRULES -- Number of rules. */ -#define YYNRULES 54 +#define YYNRULES 58 /* YYNRULES -- Number of states. */ -#define YYNSTATES 88 +#define YYNSTATES 99 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -287,9 +287,9 @@ static const unsigned char yyprhs[] = 0, 0, 3, 5, 8, 9, 11, 13, 15, 18, 22, 26, 28, 29, 31, 34, 36, 38, 40, 43, 46, 49, 52, 54, 56, 58, 61, 63, 65, 67, - 69, 71, 75, 81, 84, 86, 90, 93, 97, 100, - 102, 106, 110, 116, 120, 122, 128, 130, 134, 138, - 141, 145, 149, 152, 154 + 69, 71, 75, 78, 80, 84, 87, 91, 94, 96, + 100, 103, 107, 110, 112, 116, 120, 126, 130, 132, + 138, 140, 144, 148, 151, 155, 159, 162, 164 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -301,16 +301,17 @@ static const yysigned_char yyrhs[] = -1, 28, 12, -1, 13, -1, 12, -1, 13, -1, 30, 31, -1, 5, 32, -1, 6, 32, -1, 3, 32, -1, 4, -1, 7, -1, 8, -1, 5, 33, - -1, 9, -1, 34, -1, 37, -1, 39, -1, 44, - -1, 28, 36, 29, -1, 28, 5, 30, 36, 29, - -1, 14, 27, -1, 35, -1, 36, 30, 35, -1, - 36, 30, -1, 17, 38, 18, -1, 17, 18, -1, - 25, -1, 38, 21, 25, -1, 28, 42, 29, -1, - 28, 5, 30, 42, 29, -1, 32, 15, 27, -1, - 40, -1, 22, 25, 30, 15, 27, -1, 41, -1, - 42, 30, 35, -1, 42, 30, 41, -1, 42, 30, - -1, 25, 15, 27, -1, 19, 45, 20, -1, 19, - 20, -1, 43, -1, 45, 21, 43, -1 + -1, 9, -1, 34, -1, 38, -1, 40, -1, 45, + -1, 28, 36, 29, -1, 14, 27, -1, 37, -1, + 5, 30, 36, -1, 5, 36, -1, 3, 30, 36, + -1, 3, 36, -1, 35, -1, 37, 30, 35, -1, + 37, 30, -1, 17, 39, 18, -1, 17, 18, -1, + 25, -1, 39, 21, 25, -1, 28, 43, 29, -1, + 28, 5, 30, 43, 29, -1, 32, 15, 27, -1, + 41, -1, 22, 25, 30, 15, 27, -1, 42, -1, + 43, 30, 35, -1, 43, 30, 42, -1, 43, 30, + -1, 25, 15, 27, -1, 19, 46, 20, -1, 19, + 20, -1, 44, -1, 46, 21, 44, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -319,9 +320,9 @@ static const unsigned short yyrline[] = 0, 44, 44, 48, 52, 58, 59, 62, 63, 72, 76, 82, 83, 101, 102, 105, 108, 111, 112, 120, 125, 133, 137, 145, 158, 165, 170, 171, 172, 173, - 174, 180, 184, 191, 197, 201, 206, 215, 219, 225, - 229, 239, 244, 252, 267, 268, 276, 277, 289, 296, - 305, 313, 317, 323, 324 + 174, 180, 186, 192, 193, 198, 203, 207, 213, 217, + 222, 231, 235, 241, 245, 255, 260, 268, 283, 284, + 292, 293, 305, 312, 321, 329, 333, 339, 340 }; #endif @@ -335,9 +336,10 @@ static const char *const yytname[] = "':'", "'+'", "'['", "']'", "'{'", "'}'", "','", "'?'", "$accept", "doc", "atom", "ind_rep", "atom_or_empty", "indent_open", "indent_end", "indent_sep", "indent_flex_end", "word_rep", "struct_rep", - "implicit_seq", "basic_seq", "in_implicit_seq", "inline_seq", - "in_inline_seq", "implicit_map", "basic_mapping", "complex_mapping", - "in_implicit_map", "basic_mapping2", "inline_map", "in_inline_map", 0 + "implicit_seq", "basic_seq", "top_imp_seq", "in_implicit_seq", + "inline_seq", "in_inline_seq", "implicit_map", "basic_mapping", + "complex_mapping", "in_implicit_map", "basic_mapping2", "inline_map", + "in_inline_map", 0 }; #endif @@ -358,9 +360,9 @@ static const unsigned char yyr1[] = 0, 23, 24, 24, 24, 25, 25, 26, 26, 26, 26, 27, 27, 28, 28, 29, 30, 31, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, - 33, 34, 34, 35, 36, 36, 36, 37, 37, 38, - 38, 39, 39, 40, 41, 41, 42, 42, 42, 42, - 43, 44, 44, 45, 45 + 33, 34, 35, 36, 36, 36, 36, 36, 37, 37, + 37, 38, 38, 39, 39, 40, 40, 41, 42, 42, + 43, 43, 43, 43, 44, 45, 45, 46, 46 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -369,9 +371,9 @@ static const unsigned char yyr2[] = 0, 2, 1, 2, 0, 1, 1, 1, 2, 3, 3, 1, 0, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, - 1, 3, 5, 2, 1, 3, 2, 3, 2, 1, - 3, 3, 5, 3, 1, 5, 1, 3, 3, 2, - 3, 3, 2, 1, 3 + 1, 3, 2, 1, 3, 2, 3, 2, 1, 3, + 2, 3, 2, 1, 3, 3, 5, 3, 1, 5, + 1, 3, 3, 2, 3, 3, 2, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -381,45 +383,47 @@ static const unsigned char yydefact[] = { 4, 0, 26, 12, 13, 0, 0, 0, 0, 2, 27, 28, 29, 30, 25, 0, 22, 0, 0, 23, - 24, 11, 6, 3, 0, 5, 7, 38, 39, 0, - 52, 0, 53, 0, 1, 0, 0, 14, 12, 0, - 0, 34, 0, 44, 46, 0, 8, 21, 19, 0, - 20, 0, 0, 0, 37, 0, 12, 51, 0, 16, - 0, 33, 0, 12, 15, 31, 36, 41, 49, 17, - 0, 10, 9, 40, 50, 54, 0, 0, 0, 43, - 35, 47, 48, 18, 32, 42, 12, 45 + 24, 11, 6, 3, 0, 5, 7, 42, 43, 0, + 56, 0, 57, 0, 1, 0, 0, 14, 12, 0, + 0, 38, 0, 33, 48, 50, 0, 8, 21, 0, + 19, 0, 20, 0, 0, 0, 0, 41, 0, 12, + 55, 0, 0, 16, 0, 37, 0, 35, 32, 0, + 12, 15, 31, 40, 45, 53, 0, 17, 0, 10, + 9, 44, 54, 58, 0, 0, 0, 36, 34, 0, + 0, 47, 39, 51, 52, 18, 46, 12, 49 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yysigned_char yydefgoto[] = { - -1, 7, 21, 22, 23, 24, 65, 70, 71, 25, - 26, 10, 41, 42, 11, 29, 12, 43, 44, 45, - 32, 13, 33 + -1, 7, 21, 22, 23, 24, 72, 64, 79, 25, + 26, 10, 41, 67, 43, 11, 29, 12, 44, 45, + 46, 32, 13, 33 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -51 +#define YYPACT_NINF -47 static const short yypact[] = { - 13, 188, -51, 166, -51, 132, 114, 19, 90, -51, - -51, -51, -51, -51, -51, 166, -51, 183, 61, -51, - -51, -51, -51, -51, 70, -51, -51, -51, -51, -7, - -51, 10, -51, 18, -51, 61, 205, -51, 166, 166, - 27, -51, 46, -51, -51, 46, -51, -51, -51, 61, - -51, 149, 49, 32, -51, 166, 166, -51, 166, -51, - 102, -51, 38, 166, -51, -51, 39, -51, 102, -51, - 49, -51, -51, -51, -51, -51, 46, 46, 55, -51, - -51, -51, -51, -51, -51, -51, 166, -51 + 4, 241, -47, 219, -47, 202, 150, 2, 114, -47, + -47, -47, -47, -47, -47, 219, -47, 236, 276, -47, + -47, -47, -47, -47, 94, -47, -47, -47, -47, 8, + -47, 10, -47, -9, -47, 258, 258, -47, 219, 219, + 15, -47, 29, 37, -47, -47, 6, -47, -47, 276, + -47, 276, -47, 168, 185, 23, 35, -47, 219, 219, + -47, 219, 258, -47, 81, -47, 126, -47, -47, 37, + 219, -47, -47, 39, -47, 138, 185, -47, 23, -47, + -47, -47, -47, -47, 81, 264, 264, -47, -47, 6, + 40, -47, -47, -47, -47, -47, -47, 219, -47 }; /* YYPGOTO[NTERM-NUM]. */ static const yysigned_char yypgoto[] = { - -51, -51, -4, -9, -30, 4, -28, -5, -50, -8, - 12, -51, -32, 20, -51, -51, -51, -51, 15, 25, - 28, -51, -51 + -47, -47, 32, -7, -31, 3, -45, 18, -46, 16, + 5, -47, -32, -8, -47, -47, -47, -47, -47, -15, + -4, 7, -47, -47 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -429,54 +433,68 @@ static const yysigned_char yypgoto[] = #define YYTABLE_NINF -1 static const unsigned char yytable[] = { - 40, 28, 31, 72, 8, 8, 46, 47, 61, 48, - 50, 54, 9, 14, 55, 52, 53, 67, 1, 34, - 83, 8, 2, 3, 4, 56, 74, 47, 48, 14, - 5, 60, 6, 79, 80, 62, 81, 66, 57, 58, - 68, 48, 63, 48, 59, 69, 60, 63, 84, 85, - 59, 73, 40, 38, 31, 8, 87, 78, 59, 64, - 40, 59, 69, 14, 35, 16, 49, 18, 19, 20, - 86, 66, 68, 15, 16, 51, 18, 19, 20, 2, - 76, 4, 37, 82, 38, 77, 75, 5, 0, 6, - 0, 0, 39, 35, 16, 36, 18, 19, 20, 0, - 0, 0, 37, 0, 38, 35, 16, 49, 18, 19, - 20, 0, 39, 0, 0, 0, 38, 15, 16, 17, - 18, 19, 20, 2, 39, 4, 0, 0, 0, 0, - 0, 5, 0, 6, 30, 15, 16, 17, 18, 19, + 42, 74, 34, 8, 8, 9, 14, 68, 47, 1, + 80, 60, 61, 2, 3, 4, 42, 55, 63, 71, + 8, 5, 14, 6, 40, 59, 57, 65, 82, 58, + 70, 48, 95, 50, 52, 63, 77, 28, 31, 91, + 56, 92, 71, 93, 96, 65, 47, 63, 77, 63, + 70, 48, 50, 38, 66, 97, 87, 8, 88, 14, + 94, 73, 89, 0, 75, 48, 98, 50, 83, 48, + 50, 69, 66, 78, 78, 0, 88, 65, 50, 8, + 84, 14, 40, 0, 85, 0, 86, 90, 0, 0, + 81, 40, 50, 31, 84, 38, 78, 53, 16, 54, + 18, 19, 20, 2, 84, 4, 37, 75, 38, 0, + 0, 5, 0, 6, 0, 0, 39, 35, 16, 36, + 18, 19, 20, 0, 0, 0, 37, 0, 38, 35, + 16, 62, 18, 19, 20, 0, 39, 0, 0, 0, + 38, 49, 16, 51, 18, 19, 20, 0, 39, 0, + 0, 0, 38, 15, 16, 17, 18, 19, 20, 2, + 39, 4, 0, 0, 0, 0, 0, 5, 0, 6, + 30, 53, 16, 76, 18, 19, 20, 2, 0, 4, + 63, 0, 38, 0, 0, 5, 0, 6, 35, 16, + 76, 18, 19, 20, 2, 0, 4, 63, 0, 38, + 0, 0, 5, 0, 6, 15, 16, 17, 18, 19, 20, 2, 0, 4, 0, 0, 0, 0, 0, 5, - 27, 6, 35, 16, 17, 18, 19, 20, 2, 0, - 4, 59, 0, 0, 0, 0, 5, 0, 6, 15, - 16, 17, 18, 19, 20, 2, 0, 4, 0, 0, - 0, 0, 0, 5, 0, 6, 35, 16, 17, 18, - 19, 20, 2, 1, 4, 0, 0, 2, 0, 4, - 5, 0, 6, 0, 0, 5, 0, 6, 35, 16, - 49, 18, 19, 20, 0, 0, 0, 59 + 27, 6, 15, 16, 17, 18, 19, 20, 2, 0, + 4, 0, 0, 0, 0, 0, 5, 0, 6, 49, + 16, 17, 18, 19, 20, 2, 1, 4, 0, 0, + 2, 0, 4, 5, 0, 6, 0, 0, 5, 0, + 6, 35, 16, 62, 18, 19, 20, 85, 0, 86, + 63, 0, 38, 0, 0, 0, 63, 0, 38, 49, + 16, 51, 18, 19, 20 }; static const yysigned_char yycheck[] = { - 8, 5, 6, 53, 0, 1, 15, 15, 38, 17, - 18, 18, 0, 1, 21, 24, 24, 45, 5, 0, - 70, 17, 9, 10, 11, 15, 56, 35, 36, 17, - 17, 36, 19, 63, 66, 39, 68, 42, 20, 21, - 45, 49, 15, 51, 12, 13, 51, 15, 76, 77, - 12, 55, 60, 14, 58, 51, 86, 62, 12, 13, - 68, 12, 13, 51, 3, 4, 5, 6, 7, 8, - 15, 76, 77, 3, 4, 5, 6, 7, 8, 9, - 60, 11, 12, 68, 14, 60, 58, 17, -1, 19, - -1, -1, 22, 3, 4, 5, 6, 7, 8, -1, - -1, -1, 12, -1, 14, 3, 4, 5, 6, 7, - 8, -1, 22, -1, -1, -1, 14, 3, 4, 5, - 6, 7, 8, 9, 22, 11, -1, -1, -1, -1, - -1, 17, -1, 19, 20, 3, 4, 5, 6, 7, + 8, 46, 0, 0, 1, 0, 1, 38, 15, 5, + 56, 20, 21, 9, 10, 11, 24, 24, 12, 13, + 17, 17, 17, 19, 8, 15, 18, 35, 59, 21, + 15, 15, 78, 17, 18, 12, 13, 5, 6, 70, + 24, 73, 13, 75, 89, 53, 53, 12, 13, 12, + 15, 35, 36, 14, 36, 15, 64, 54, 66, 54, + 75, 43, 66, -1, 46, 49, 97, 51, 61, 53, + 54, 39, 54, 55, 56, -1, 84, 85, 62, 76, + 62, 76, 66, -1, 3, -1, 5, 69, -1, -1, + 58, 75, 76, 61, 76, 14, 78, 3, 4, 5, + 6, 7, 8, 9, 86, 11, 12, 89, 14, -1, + -1, 17, -1, 19, -1, -1, 22, 3, 4, 5, + 6, 7, 8, -1, -1, -1, 12, -1, 14, 3, + 4, 5, 6, 7, 8, -1, 22, -1, -1, -1, + 14, 3, 4, 5, 6, 7, 8, -1, 22, -1, + -1, -1, 14, 3, 4, 5, 6, 7, 8, 9, + 22, 11, -1, -1, -1, -1, -1, 17, -1, 19, + 20, 3, 4, 5, 6, 7, 8, 9, -1, 11, + 12, -1, 14, -1, -1, 17, -1, 19, 3, 4, + 5, 6, 7, 8, 9, -1, 11, 12, -1, 14, + -1, -1, 17, -1, 19, 3, 4, 5, 6, 7, 8, 9, -1, 11, -1, -1, -1, -1, -1, 17, 18, 19, 3, 4, 5, 6, 7, 8, 9, -1, - 11, 12, -1, -1, -1, -1, 17, -1, 19, 3, - 4, 5, 6, 7, 8, 9, -1, 11, -1, -1, - -1, -1, -1, 17, -1, 19, 3, 4, 5, 6, - 7, 8, 9, 5, 11, -1, -1, 9, -1, 11, - 17, -1, 19, -1, -1, 17, -1, 19, 3, 4, - 5, 6, 7, 8, -1, -1, -1, 12 + 11, -1, -1, -1, -1, -1, 17, -1, 19, 3, + 4, 5, 6, 7, 8, 9, 5, 11, -1, -1, + 9, -1, 11, 17, -1, 19, -1, -1, 17, -1, + 19, 3, 4, 5, 6, 7, 8, 3, -1, 5, + 12, -1, 14, -1, -1, -1, 12, -1, 14, 3, + 4, 5, 6, 7, 8 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -484,14 +502,15 @@ static const yysigned_char yycheck[] = static const unsigned char yystos[] = { 0, 5, 9, 10, 11, 17, 19, 24, 28, 33, - 34, 37, 39, 44, 33, 3, 4, 5, 6, 7, - 8, 25, 26, 27, 28, 32, 33, 18, 25, 38, - 20, 25, 43, 45, 0, 3, 5, 12, 14, 22, - 32, 35, 36, 40, 41, 42, 26, 32, 32, 5, - 32, 5, 26, 32, 18, 21, 15, 20, 21, 12, - 30, 27, 25, 15, 13, 29, 30, 29, 30, 13, - 30, 31, 31, 25, 27, 43, 36, 42, 30, 27, - 35, 35, 41, 31, 29, 29, 15, 27 + 34, 38, 40, 45, 33, 3, 4, 5, 6, 7, + 8, 25, 26, 27, 28, 32, 33, 18, 25, 39, + 20, 25, 44, 46, 0, 3, 5, 12, 14, 22, + 32, 35, 36, 37, 41, 42, 43, 26, 32, 3, + 32, 5, 32, 3, 5, 26, 32, 18, 21, 15, + 20, 21, 5, 12, 30, 36, 30, 36, 27, 25, + 15, 13, 29, 30, 29, 30, 5, 13, 30, 31, + 31, 25, 27, 44, 30, 3, 5, 36, 36, 43, + 30, 27, 35, 35, 42, 31, 29, 15, 27 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) @@ -1177,81 +1196,103 @@ yyreduce: break; case 32: -#line 185 "gram.y" - { - syck_add_transfer( yyvsp[-3].name, yyvsp[-1].nodeData, ((SyckParser *)parser)->taguri_expansion ); - yyval.nodeData = yyvsp[-1].nodeData; - } - break; - - case 33: -#line 192 "gram.y" +#line 187 "gram.y" { yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); } break; case 34: -#line 198 "gram.y" +#line 194 "gram.y" + { + syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); + yyval.nodeData = yyvsp[0].nodeData; + } + break; + + case 35: +#line 199 "gram.y" + { + syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); + yyval.nodeData = yyvsp[0].nodeData; + } + break; + + case 36: +#line 204 "gram.y" + { + yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); + } + break; + + case 37: +#line 208 "gram.y" + { + yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); + } + break; + + case 38: +#line 214 "gram.y" { yyval.nodeData = syck_new_seq( yyvsp[0].nodeId ); } break; - case 35: -#line 202 "gram.y" + case 39: +#line 218 "gram.y" { syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId ); yyval.nodeData = yyvsp[-2].nodeData; } break; - case 36: -#line 207 "gram.y" + case 40: +#line 223 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; - case 37: -#line 216 "gram.y" + case 41: +#line 232 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; - case 38: -#line 220 "gram.y" + case 42: +#line 236 "gram.y" { yyval.nodeData = syck_alloc_seq(); } break; - case 39: -#line 226 "gram.y" + case 43: +#line 242 "gram.y" { yyval.nodeData = syck_new_seq( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); } break; - case 40: -#line 230 "gram.y" + case 44: +#line 246 "gram.y" { syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); yyval.nodeData = yyvsp[-2].nodeData; } break; - case 41: -#line 240 "gram.y" + case 45: +#line 256 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); yyval.nodeData = yyvsp[-1].nodeData; } break; - case 42: -#line 245 "gram.y" + case 46: +#line 261 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); syck_add_transfer( yyvsp[-3].name, yyvsp[-1].nodeData, ((SyckParser *)parser)->taguri_expansion ); @@ -1259,8 +1300,8 @@ yyreduce: } break; - case 43: -#line 253 "gram.y" + case 47: +#line 269 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), @@ -1268,8 +1309,8 @@ yyreduce: } break; - case 45: -#line 269 "gram.y" + case 49: +#line 285 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-3].nodeData ), @@ -1277,8 +1318,8 @@ yyreduce: } break; - case 47: -#line 278 "gram.y" + case 51: +#line 294 "gram.y" { if ( yyvsp[-2].nodeData->shortcut == NULL ) { @@ -1292,8 +1333,8 @@ yyreduce: } break; - case 48: -#line 290 "gram.y" + case 52: +#line 306 "gram.y" { apply_seq_in_map( (SyckParser *)parser, yyvsp[-2].nodeData ); syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); @@ -1302,15 +1343,15 @@ yyreduce: } break; - case 49: -#line 297 "gram.y" + case 53: +#line 313 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; - case 50: -#line 306 "gram.y" + case 54: +#line 322 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), @@ -1318,22 +1359,22 @@ yyreduce: } break; - case 51: -#line 314 "gram.y" + case 55: +#line 330 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; - case 52: -#line 318 "gram.y" + case 56: +#line 334 "gram.y" { yyval.nodeData = syck_alloc_map(); } break; - case 54: -#line 325 "gram.y" + case 58: +#line 341 "gram.y" { syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); syck_free_node( yyvsp[0].nodeData ); @@ -1345,7 +1386,7 @@ yyreduce: } /* Line 1016 of /usr/local/share/bison/yacc.c. */ -#line 1349 "y.tab.c" +#line 1390 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -1564,7 +1605,7 @@ yyreturn: } -#line 332 "gram.y" +#line 348 "gram.y" void diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index 60facd501e..4d5fdb18d6 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -147,7 +147,14 @@ rb_syck_mktime(str) // Millisecond ptr += 2; - usec = INT2FIX( strtod( ptr, NULL ) * 1000000 ); + if ( *ptr == '.' ) + { + usec = INT2FIX( strtod( ptr, NULL ) * 1000000 ); + } + else + { + usec = INT2FIX( 0 ); + } // Make UTC time time = rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, usec); @@ -156,9 +163,9 @@ rb_syck_mktime(str) while ( *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++; if ( *ptr == '-' || *ptr == '+' ) { - long tz_offset = 0; + double tz_offset = 0; double utc_time = 0; - tz_offset += strtol(ptr, NULL, 10) * 3600; + tz_offset += strtod(ptr, NULL) * 3600; while ( *ptr != ':' && *ptr != '\0' ) ptr++; if ( *ptr == ':' ) @@ -166,11 +173,11 @@ rb_syck_mktime(str) ptr += 1; if ( tz_offset < 0 ) { - tz_offset -= strtol(ptr, NULL, 10) * 60; + tz_offset -= strtod(ptr, NULL) * 60; } else { - tz_offset += strtol(ptr, NULL, 10) * 60; + tz_offset += strtod(ptr, NULL) * 60; } } diff --git a/ext/syck/token.c b/ext/syck/token.c index 39ccbd8dd1..01e51bad0f 100644 --- a/ext/syck/token.c +++ b/ext/syck/token.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Thu May 29 17:58:58 2003 */ +/* Generated by re2c 0.5 on Fri May 30 15:54:17 2003 */ #line 1 "token.re" /* * token.re @@ -226,7 +226,7 @@ yylex( YYSTYPE *yylval, SyckParser *parser ) return t; } -#line 242 +#line 243 if ( YYLINEPTR != YYCURSOR ) @@ -260,19 +260,19 @@ yy2: yyaccept = 0; default: goto yy3; } yy3: -#line 283 +#line 284 { YYPOS(0); goto Document; } yy4: yych = *++YYCURSOR; yy5: -#line 269 +#line 270 { eat_comments( parser ); goto Header; } yy6: yych = *++YYCURSOR; yy7: -#line 273 +#line 274 { SyckLevel *lvl = CURRENT_LEVEL(); ENSURE_IEND(lvl, -1); return 0; @@ -280,7 +280,7 @@ yy7: yy8: yych = *++YYCURSOR; goto yy12; yy9: -#line 278 +#line 279 { int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKEN ); goto Header; @@ -325,7 +325,7 @@ yy19: switch(yych){ default: goto yy20; } yy20: -#line 255 +#line 256 { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { @@ -347,7 +347,7 @@ yy22: switch(yych){ default: goto yy20; } } -#line 287 +#line 288 Document: @@ -388,7 +388,7 @@ yy23: yy25: yych = *++YYCURSOR; goto yy77; yy26: -#line 301 +#line 302 { // Isolate spaces int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKEN ); @@ -405,7 +405,7 @@ yy26: } yy27: yych = *++YYCURSOR; yy28: -#line 316 +#line 317 { ENSURE_IOPEN(lvl, 0, 1); lvl = CURRENT_LEVEL(); ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline); @@ -413,7 +413,7 @@ yy28: } yy29: yych = *++YYCURSOR; yy30: -#line 322 +#line 323 { POP_LEVEL(); return YYTOKEN[0]; } @@ -424,7 +424,7 @@ yy31: yych = *++YYCURSOR; default: goto yy32; } yy32: -#line 380 +#line 381 { ENSURE_IOPEN(lvl, 0, 1); goto Plain; } @@ -564,17 +564,17 @@ yy35: yych = *++YYCURSOR; } yy36: yych = *++YYCURSOR; yy37: -#line 354 +#line 355 { ENSURE_IOPEN(lvl, 0, 1); goto TransferMethod; } yy38: yych = *++YYCURSOR; yy39: -#line 357 +#line 358 { ENSURE_IOPEN(lvl, 0, 1); goto SingleQuote; } yy40: yych = *++YYCURSOR; yy41: -#line 360 +#line 361 { ENSURE_IOPEN(lvl, 0, 1); goto DoubleQuote; } yy42: yyaccept = 0; @@ -596,18 +596,18 @@ yy42: yyaccept = 0; } yy43: yych = *++YYCURSOR; yy44: -#line 370 +#line 371 { eat_comments( parser ); goto Document; } yy45: yych = *++YYCURSOR; goto yy51; yy46: -#line 374 +#line 375 { goto Document; } yy47: yych = *++YYCURSOR; yy48: -#line 376 +#line 377 { ENSURE_IEND(lvl, -1); return 0; } @@ -650,7 +650,7 @@ yy56: switch(yych){ default: goto yy57; } yy57: -#line 363 +#line 364 { if ( *( YYCURSOR - 1 ) == '\n' ) { YYCURSOR--; @@ -731,7 +731,7 @@ yy61: switch(yych){ default: goto yy62; } yy62: -#line 349 +#line 350 { ENSURE_IOPEN(lvl, 0, 1); yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return ALIAS; @@ -803,7 +803,7 @@ yy64: switch(yych){ default: goto yy65; } yy65: -#line 344 +#line 345 { ENSURE_IOPEN(lvl, 0, 1); yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return ANCHOR; @@ -816,7 +816,7 @@ yy67: switch(yych){ default: goto yy68; } yy68: -#line 330 +#line 331 { ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(IOPEN); if ( *YYCURSOR == '\n' || *( YYCURSOR - 1 ) == '\n' ) @@ -845,7 +845,7 @@ yy72: switch(yych){ default: goto yy73; } yy73: -#line 326 +#line 327 { YYPOS(1); return YYTOKEN[0]; } @@ -872,7 +872,7 @@ yy79: switch(yych){ default: goto yy26; } } -#line 384 +#line 385 } @@ -964,14 +964,14 @@ yy83: yyaccept = 0; default: goto yy84; } yy84: -#line 397 +#line 398 { YYCURSOR = YYTOKTMP; return DOCSEP; } yy85: yych = *++YYCURSOR; goto yy89; yy86: -#line 395 +#line 396 { goto Directive; } yy87: yych = *++YYCURSOR; goto yy84; @@ -1180,10 +1180,10 @@ yy94: switch(yych){ default: goto yy95; } yy95: -#line 393 +#line 394 { goto Directive; } } -#line 400 +#line 401 } @@ -1225,7 +1225,7 @@ yy96: yy98: yych = *++YYCURSOR; goto yy122; yy99: -#line 423 +#line 424 { int indt_len, nl_count = 0; SyckLevel *lvl; char *tok = YYTOKTMP; @@ -1264,13 +1264,13 @@ yy100: yych = *++YYCURSOR; default: goto yy101; } yy101: -#line 474 +#line 475 { QUOTECATS(qstr, qcapa, qidx, YYTOKTMP, YYCURSOR - YYTOKTMP); goto Plain2; } yy102: yych = *++YYCURSOR; yy103: -#line 457 +#line 458 { if ( plvl->status != syck_lvl_inline ) { YYCURSOR--; @@ -1291,17 +1291,17 @@ yy105: yych = *++YYCURSOR; default: goto yy106; } yy106: -#line 472 +#line 473 { goto Plain3; } yy107: yych = *++YYCURSOR; yy108: -#line 470 +#line 471 { RETURN_IMPLICIT(); } yy109: yych = *++YYCURSOR; goto yy101; yy110: yych = *++YYCURSOR; yy111: -#line 466 +#line 467 { eat_comments( parser ); RETURN_IMPLICIT(); } @@ -1327,7 +1327,7 @@ yy117: switch(yych){ default: goto yy118; } yy118: -#line 455 +#line 456 { RETURN_IMPLICIT(); } yy119: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1352,7 +1352,7 @@ yy124: switch(yych){ default: goto yy99; } } -#line 478 +#line 479 } @@ -1382,7 +1382,7 @@ yy125: yy127: yych = *++YYCURSOR; goto yy137; yy128: -#line 492 +#line 493 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1424,7 +1424,7 @@ yy129: yych = *++YYCURSOR; default: goto yy130; } yy130: -#line 532 +#line 533 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1442,13 +1442,13 @@ yy131: yych = *++YYCURSOR; goto yy130; yy132: yych = *++YYCURSOR; yy133: -#line 546 +#line 547 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } yy134: yych = *++YYCURSOR; yy135: -#line 528 +#line 529 { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } @@ -1468,7 +1468,7 @@ yy139: switch(yych){ default: goto yy128; } } -#line 550 +#line 551 } @@ -1491,7 +1491,7 @@ DoubleQuote2: goto yy140; yy141: ++YYCURSOR; yy140: - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch(yych){ case '\000': goto yy146; @@ -1501,9 +1501,9 @@ yy140: default: goto yy149; } yy142: yych = *++YYCURSOR; - goto yy158; + goto yy162; yy143: -#line 568 +#line 569 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1550,17 +1550,18 @@ yy144: yyaccept = 0; case ' ': goto yy150; case '"': case '\\': case 'a': case 'b': case 'e': - case 'f': case 'n': case 'r': case 't': case 'v': goto yy155; + case 'f': case 'n': case 'r': case 't': case 'v': goto yy156; + case 'x': goto yy155; default: goto yy145; } yy145: -#line 643 +#line 653 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } yy146: yych = *++YYCURSOR; yy147: -#line 629 +#line 639 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1592,14 +1593,38 @@ yy152: YYCURSOR = YYMARKER; } yy153: yych = *++YYCURSOR; yy154: -#line 624 +#line 634 { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; } yy155: yych = *++YYCURSOR; -yy156: -#line 608 + switch(yych){ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy158; + default: goto yy152; + } +yy156: yych = *++YYCURSOR; +yy157: +#line 609 { char ch = *( YYCURSOR - 1 ); switch ( ch ) { @@ -1615,23 +1640,58 @@ yy156: QUOTECAT(qstr, qcapa, qidx, ch); goto DoubleQuote2; } -yy157: ++YYCURSOR; +yy158: yych = *++YYCURSOR; + switch(yych){ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy159; + default: goto yy152; + } +yy159: yych = *++YYCURSOR; +yy160: +#line 625 + { long ch; + char *chr_text = syck_strndup( YYTOKTMP, 4 ); + chr_text[0] = '0'; + ch = strtol( chr_text, NULL, 16 ); + free( chr_text ); + QUOTECAT(qstr, qcapa, qidx, ch); + goto DoubleQuote2; + } +yy161: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy158: switch(yych){ - case '\n': goto yy157; - case ' ': goto yy159; +yy162: switch(yych){ + case '\n': goto yy161; + case ' ': goto yy163; default: goto yy143; } -yy159: ++YYCURSOR; +yy163: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy160: switch(yych){ - case '\n': case ' ': goto yy159; +yy164: switch(yych){ + case '\n': case ' ': goto yy163; default: goto yy143; } } -#line 647 +#line 657 } @@ -1642,21 +1702,21 @@ TransferMethod: { YYCTYPE yych; unsigned int yyaccept; - goto yy161; -yy162: ++YYCURSOR; -yy161: + goto yy165; +yy166: ++YYCURSOR; +yy165: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ - case '\000': goto yy163; - case '\n': goto yy166; - case ' ': goto yy164; - default: goto yy167; + case '\000': goto yy167; + case '\n': goto yy170; + case ' ': goto yy168; + default: goto yy171; } -yy163:yy164: yych = *++YYCURSOR; - goto yy172; -yy165: -#line 656 +yy167:yy168: yych = *++YYCURSOR; + goto yy176; +yy169: +#line 666 { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) @@ -1702,28 +1762,28 @@ yy165: return TRANSFER; } -yy166: yych = *++YYCURSOR; - goto yy170; -yy167: yych = *++YYCURSOR; -yy168: -#line 702 +yy170: yych = *++YYCURSOR; + goto yy174; +yy171: yych = *++YYCURSOR; +yy172: +#line 712 { goto TransferMethod; } -yy169: ++YYCURSOR; +yy173: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy170: switch(yych){ - case '\n': goto yy169; - default: goto yy165; +yy174: switch(yych){ + case '\n': goto yy173; + default: goto yy169; } -yy171: ++YYCURSOR; +yy175: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy172: switch(yych){ - case ' ': goto yy171; - default: goto yy165; +yy176: switch(yych){ + case ' ': goto yy175; + default: goto yy169; } } -#line 704 +#line 714 } @@ -1773,20 +1833,21 @@ ScalarBlock2: { YYCTYPE yych; unsigned int yyaccept; - goto yy173; -yy174: ++YYCURSOR; -yy173: + goto yy177; +yy178: ++YYCURSOR; +yy177: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ - case '\000': goto yy177; - case '\n': goto yy175; - default: goto yy179; + case '\000': goto yy183; + case '\n': goto yy179; + case '#': goto yy181; + default: goto yy185; } -yy175: yych = *++YYCURSOR; - goto yy182; -yy176: -#line 752 +yy179: yych = *++YYCURSOR; + goto yy188; +yy180: +#line 762 { char *pacer; char *tok = YYTOKTMP; int indt_len = 0, nl_count = 0, fold_nl = 0; @@ -1854,36 +1915,51 @@ yy176: } goto ScalarBlock2; } -yy177: yych = *++YYCURSOR; -yy178: -#line 821 +yy181: yych = *++YYCURSOR; +yy182: +#line 831 + { lvl = CURRENT_LEVEL(); + if ( lvl->status != syck_lvl_block ) + { + eat_comments( parser ); + YYTOKTMP = YYCURSOR; + } + else + { + QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP); + } + goto ScalarBlock2; + } +yy183: yych = *++YYCURSOR; +yy184: +#line 845 { YYCURSOR--; POP_LEVEL(); RETURN_BLOCK(); } -yy179: yych = *++YYCURSOR; -yy180: -#line 826 +yy185: yych = *++YYCURSOR; +yy186: +#line 850 { QUOTECAT(qstr, qcapa, qidx, *YYTOKTMP); goto ScalarBlock2; } -yy181: ++YYCURSOR; +yy187: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy182: switch(yych){ - case '\n': goto yy181; - case ' ': goto yy183; - default: goto yy176; +yy188: switch(yych){ + case '\n': goto yy187; + case ' ': goto yy189; + default: goto yy180; } -yy183: ++YYCURSOR; +yy189: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy184: switch(yych){ - case '\n': case ' ': goto yy183; - default: goto yy176; +yy190: switch(yych){ + case '\n': case ' ': goto yy189; + default: goto yy180; } } -#line 831 +#line 855 } @@ -1901,39 +1977,39 @@ Comment: { YYCTYPE yych; unsigned int yyaccept; - goto yy185; -yy186: ++YYCURSOR; -yy185: + goto yy191; +yy192: ++YYCURSOR; +yy191: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ - case '\000': goto yy187; - case '\n': goto yy189; - default: goto yy190; + case '\000': goto yy193; + case '\n': goto yy195; + default: goto yy196; } -yy187: yych = *++YYCURSOR; -yy188: -#line 847 +yy193: yych = *++YYCURSOR; +yy194: +#line 871 { SyckLevel *lvl = CURRENT_LEVEL(); YYCURSOR = tok; return; } -yy189: yych = *++YYCURSOR; - goto yy193; -yy190: yych = *++YYCURSOR; -yy191: -#line 852 +yy195: yych = *++YYCURSOR; + goto yy199; +yy196: yych = *++YYCURSOR; +yy197: +#line 876 { goto Comment; } -yy192: ++YYCURSOR; +yy198: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy193: switch(yych){ - case '\n': goto yy192; - default: goto yy188; +yy199: switch(yych){ + case '\n': goto yy198; + default: goto yy194; } } -#line 855 +#line 879 } diff --git a/lib/yaml/basenode.rb b/lib/yaml/basenode.rb index 341177a979..e88a76f3d2 100644 --- a/lib/yaml/basenode.rb +++ b/lib/yaml/basenode.rb @@ -25,7 +25,7 @@ module YAML matches.each { |m| result.push m.last } - YamlNode.new( 'seq', result ) + self.class.new( 'seq', result ) end end @@ -163,7 +163,7 @@ module YAML #puts "DEPTH: #{depth + 1}" deep_nodes = [] match_nodes.each { |n| - if n[1].is_a? YamlNode + if n[1].is_a? BaseNode match_deep = n[1].match_segment( ypath, depth + 1 ) if match_deep match_deep.each { |m|