From 1c024b77912aabf771d798c934d8d355ab14ef17 Mon Sep 17 00:00:00 2001 From: Bart Debersaques Date: Wed, 21 Jan 2026 16:48:24 +0100 Subject: [PATCH] fix:: applies pattern of c_double_quoted to provide c_single_quoted, uncommented in c_flow_json_content in occordence to https://yaml.org/spec/1.2.2/#rule-c-flow-json-content as shared missing in https://github.com/moosetechnology/PetitParser/issues/66 --- .../PPYAMLGrammarTest.class.st | 180 ++++----- src/PetitYAML-Tests/package.st | 2 +- src/PetitYAML/PPContext.extension.st | 22 +- src/PetitYAML/PPParser.extension.st | 26 +- src/PetitYAML/PPYAMLGrammar.class.st | 342 +++++++++++------- src/PetitYAML/PPYAMLGrammarTest.class.st | 167 ++++----- src/PetitYAML/package.st | 2 +- 7 files changed, 421 insertions(+), 320 deletions(-) diff --git a/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st b/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st index 7529d2a..b9bda77 100644 --- a/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st +++ b/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st @@ -1,18 +1,19 @@ Class { - #name : #PPYAMLGrammarTest, - #superclass : #PPCompositeParserTest, + #name : 'PPYAMLGrammarTest', + #superclass : 'PPCompositeParserTest', #instVars : [ 'context' ], - #category : #'PetitYAML-Tests' + #category : 'PetitYAML-Tests', + #package : 'PetitYAML-Tests' } -{ #category : #accessing } +{ #category : 'accessing' } PPYAMLGrammarTest >> context [ ^ context ] -{ #category : #parsing } +{ #category : 'parsing' } PPYAMLGrammarTest >> debug: aString rule: aSymbol [ | production | production := self parserInstanceFor: aSymbol. @@ -26,18 +27,18 @@ PPYAMLGrammarTest >> debug: aString rule: aSymbol [ ^ result ] -{ #category : #accessing } +{ #category : 'accessing' } PPYAMLGrammarTest >> parserClass [ ^ PPYAMLGrammar ] -{ #category : #running } +{ #category : 'running' } PPYAMLGrammarTest >> setUp [ super setUp. context := PPContext new. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument [ | string | string :='receipt: Oz-Ware Purchase Invoice'. @@ -47,7 +48,7 @@ PPYAMLGrammarTest >> testDocument [ self assert: (result at: 'receipt') = 'Oz-Ware Purchase Invoice' ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument1 [ | string | string :='receipt: Oz-Ware Purchase Invoice @@ -76,7 +77,7 @@ items: ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument2 [ | string | string :='receipt: Oz-Ware Purchase Invoice @@ -90,7 +91,7 @@ customer: self assert: ((result at: 'customer') at: #family) = 'Gale' ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testMappingClipStripKeep [ | string | @@ -112,7 +113,7 @@ keep: |+ self assert: (result at: 'keep') = String cr. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testSequence [ | string | context YAMLN: 1. @@ -127,7 +128,7 @@ PPYAMLGrammarTest >> testSequence [ self assert: (result first at: 'three') = 'four'. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testSequence2 [ | string | string := @@ -141,7 +142,7 @@ PPYAMLGrammarTest >> testSequence2 [ self assert: result size = 4. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testTravisYml [ | string | string :='language: c @@ -269,7 +270,7 @@ deploy: ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_chomped_last [ context YAMLChomp: #'strip'. self parse: ' @@ -287,7 +288,7 @@ PPYAMLGrammarTest >> test_b_chomped_last [ self assert: result = String cr. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_l_folded [ self parse: ' ' rule: #b_l_folded. @@ -306,7 +307,7 @@ PPYAMLGrammarTest >> test_b_l_folded [ self assert: result = (String cr, String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_l_trimmed [ self parse: ' @@ -321,7 +322,7 @@ PPYAMLGrammarTest >> test_b_l_trimmed [ self assert: result = (String cr, String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_nb_literal_next [ context YAMLContext: #'block-in'. context YAMLN: 3. @@ -337,7 +338,7 @@ PPYAMLGrammarTest >> test_b_nb_literal_next [ self assert: result = (String cr, String cr, ' abc'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_double_qouted [ self parse: '"hi there"' rule: #c_double_quoted. self assert: result = 'hi there'. @@ -350,13 +351,13 @@ PPYAMLGrammarTest >> test_c_double_qouted [ 2nd non-empty 3rd non-empty ' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_json_content [ self parse: '"a"' rule: #c_flow_json_content. self assert: result = 'a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_mapping [ self parse: '{ one : two , three: four , }' rule: #c_flow_mapping. self assert: result size = 2. @@ -397,7 +398,7 @@ omitted value:, ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_sequence [ self parse: '[three ,four, five]' rule: #c_flow_sequence. self assert: result size = 3. @@ -436,7 +437,7 @@ foo: bar self assert: result second = 'b' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_entry [ context YAMLN: 1. context YAMLM: 1. @@ -459,7 +460,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_entry [ self assert: result value second = 'two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_key [ context YAMLN: 1. context YAMLM: 1. @@ -475,7 +476,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_key [ self assert: result = ('block key', String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_value [ context YAMLN: 1. context YAMLM: 1. @@ -490,7 +491,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_value [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_implict_value [ context YAMLContext: #'block-in'. self parse: ': in-line value' rule: #c_l_block_map_implicit_value. @@ -510,7 +511,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_implict_value [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_sequence_entry [ context YAMLContext: #'block-in'. context YAMLM: 1. @@ -526,7 +527,7 @@ PPYAMLGrammarTest >> test_c_l_block_sequence_entry [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_folded [ self parse: '> folded @@ -564,7 +565,7 @@ last line '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal [ self parse: '| literal @@ -593,7 +594,7 @@ text ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_chomping [ self parse: '|- text @@ -617,7 +618,7 @@ PPYAMLGrammarTest >> test_c_l_literal_chomping [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_failures [ context YAMLContext: #'block-in'. "Should fail, but it does not, probably have to add some functionality to auto-detect" @@ -635,7 +636,7 @@ PPYAMLGrammarTest >> test_c_l_literal_failures [ text' rule: #c_l_literal. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_strip [ self parse: '|- # text @@ -647,7 +648,20 @@ PPYAMLGrammarTest >> test_c_l_literal_strip [ self assert: result = '# text' ] -{ #category : #spec } +{ #category : 'spec' } +PPYAMLGrammarTest >> test_c_single_qouted [ + self parse: '''hi there''' rule: #c_single_quoted. + self assert: result = 'hi there'. + + self parse: ''' 1st non-empty + + 2nd non-empty + 3rd non-empty ''' rule: #c_single_quoted. + self assert: result = ' 1st non-empty +2nd non-empty 3rd non-empty ' +] + +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_block_mapping [ context YAMLN: -1. context YAMLContext: #'block-in'. @@ -685,7 +699,7 @@ PPYAMLGrammarTest >> test_l_block_mapping [ self assert: (result at: 'quoted key') first = 'entry'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_block_sequence [ context YAMLContext: #'block-in'. self parse: ' - foo @@ -719,19 +733,19 @@ PPYAMLGrammarTest >> test_l_block_sequence [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_comment [ self parse: ' # whatever' rule: #l_comment. self fail: '' rule: #l_comment. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty [ self test_l_empty_blockIn. self test_l_empty_flowIn. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty_blockIn [ context YAMLContext: #'block-in'. context YAMLN: 3. @@ -748,7 +762,7 @@ PPYAMLGrammarTest >> test_l_empty_blockIn [ ' rule: #l_empty. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty_flowIn [ context YAMLContext: #'flow-in'. context YAMLN: 3. @@ -763,14 +777,14 @@ PPYAMLGrammarTest >> test_l_empty_flowIn [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_keep_empty [ self parse: ' ' rule: #l_keep_empty. self assert: result = String cr. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text [ context YAMLN: 3. context YAMLContext: #'block-in'. @@ -800,7 +814,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text [ self assert: result = (String cr, String cr, 'literal'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text_failures [ context YAMLN: 3. context YAMLContext: #'block-in'. @@ -813,7 +827,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text_failures [ abc' rule: #l_nb_literal_text. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text_flowIn [ context YAMLN: 3. context YAMLContext: #'flow-in'. @@ -826,7 +840,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text_flowIn [ self assert: result = (String cr, ' '). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_spaced_lines [ self parse: ' * bullet @@ -835,7 +849,7 @@ PPYAMLGrammarTest >> test_l_nb_spaced_lines [ "TODO JK: add asserts" ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_multi_line [ self parse: 'hi there' rule: #nb_double_multi_line. self assert: result = 'hi there'. @@ -852,34 +866,34 @@ PPYAMLGrammarTest >> test_nb_double_multi_line [ 2nd non-empty 3rd non-empty ' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_one_line [ self parse: 'hi there' rule: #nb_double_one_line. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_qouted [ self parse: '"hi there"' rule: #c_double_quoted. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_text [ self parse: 'hi there' rule: #nb_double_text. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_json [ self parse: ' ' rule: #nb_json. self parse: 'a' rule: #nb_json. self fail: String cr rule: #nb_json. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_ns_double_in_line [ self parse: 'hi there' rule: #nb_ns_double_in_line. self assert: result = 'hi there'. @@ -891,7 +905,7 @@ PPYAMLGrammarTest >> test_nb_ns_double_in_line [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_entry [ self parse: '? explicit: entry' rule: #ns_flow_map_entry. self assert: result = ('explicit' -> 'entry'). @@ -903,7 +917,7 @@ PPYAMLGrammarTest >> test_ns_flow_map_entry [ self assert: result = ('implicit' -> 'entry'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_explicit_entry [ self parse: 'explicit: entry' rule: #ns_flow_map_explicit_entry. self assert: result = ('explicit' -> 'entry'). @@ -912,13 +926,13 @@ PPYAMLGrammarTest >> test_ns_flow_map_explicit_entry [ self assert: result = (nil -> nil). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_implicit_entry [ self parse: 'implicit: entry' rule: #ns_flow_map_implicit_entry. self assert: result = ('implicit' -> 'entry'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_node [ self parse: 'simple text' rule: #ns_flow_node. self assert: result = 'simple text'. @@ -939,7 +953,7 @@ PPYAMLGrammarTest >> test_ns_flow_node [ self assert: result size = 1. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_pair [ self parse: 'single: pair' rule: #ns_flow_pair. @@ -947,7 +961,7 @@ PPYAMLGrammarTest >> test_ns_flow_pair [ self assert: (result at: 'single') = 'pair'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_seq_entry [ self parse: 'one' rule: #ns_flow_seq_entry. self assert: result = 'one'. @@ -956,7 +970,7 @@ PPYAMLGrammarTest >> test_ns_flow_seq_entry [ self assert: result = 'one two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_block_map_implicit_entry [ self parse: 'foo: bar' rule: #ns_l_block_map_implicit_entry. self assert: result key = 'foo'. @@ -990,7 +1004,7 @@ PPYAMLGrammarTest >> test_ns_l_block_map_implicit_entry [ self assert: result value = nil. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_compact_mapping [ self parse: 'one: two # Compact mapping' rule: #ns_l_compact_mapping. self assert: result size = 1. @@ -1016,7 +1030,7 @@ three: four' rule: #ns_l_compact_mapping. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_compact_sequence [ self parse: '- one - two' rule: #ns_l_compact_sequence. @@ -1035,7 +1049,7 @@ PPYAMLGrammarTest >> test_ns_l_compact_sequence [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain [ context YAMLContext: #'flow-in'. self parse: 'a' rule: #ns_plain. @@ -1046,7 +1060,7 @@ PPYAMLGrammarTest >> test_ns_plain [ "NOT Complete assertions..." ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_char [ self parse: 'a' rule: #ns_plain_char. @@ -1054,7 +1068,7 @@ PPYAMLGrammarTest >> test_ns_plain_char [ self fail: ':' rule: #ns_plain_char. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_multi_line [ self parse: '1st non-empty @@ -1065,7 +1079,7 @@ PPYAMLGrammarTest >> test_ns_plain_multi_line [ 2nd non-empty 3rd non-empty' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_one_line [ self parse: 'implicit block key' rule: #ns_plain_one_line. self assert: result = 'implicit block key'. @@ -1074,7 +1088,7 @@ PPYAMLGrammarTest >> test_ns_plain_one_line [ self assert: result = 'implicit:entry'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_safe_in [ self parse: 'a' rule: #ns_plain_safe_in. self parse: '+' rule: #ns_plain_safe_in. @@ -1089,7 +1103,7 @@ PPYAMLGrammarTest >> test_ns_plain_safe_in [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_safe_out [ self parse: 'a' rule: #ns_plain_safe_out. self parse: '+' rule: #ns_plain_safe_out. @@ -1099,7 +1113,7 @@ PPYAMLGrammarTest >> test_ns_plain_safe_out [ self fail: String cr rule: #ns_plain_safe_out. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_s_flow_seq_entries [ self parse: 'one, two' rule: #ns_s_flow_seq_entries. @@ -1115,14 +1129,14 @@ PPYAMLGrammarTest >> test_ns_s_flow_seq_entries [ self assert: result second = 'two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_s_implicit_yaml_key [ self parse: 'single ' rule: #ns_s_implicit_yaml_key. self assert: result = 'single'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_block_line_prefix [ context YAMLN: 3. self parse: ' ' rule: #s_block_line_prefix. @@ -1133,7 +1147,7 @@ PPYAMLGrammarTest >> test_s_block_line_prefix [ self fail: ' ' rule: #s_block_line_prefix. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_double_next_line [ self parse: ' abc' rule: #s_double_next_line. @@ -1157,7 +1171,7 @@ abc def'. self assert: result = ' abc '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_flow_folded [ self parse: ' ' rule: #s_flow_folded. @@ -1172,7 +1186,7 @@ PPYAMLGrammarTest >> test_s_flow_folded [ self fail: '' rule: #s_flow_folded. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_flow_line_prefix [ context YAMLN: 3. self parse: ' ' rule: #s_flow_line_prefix. @@ -1187,7 +1201,7 @@ PPYAMLGrammarTest >> test_s_flow_line_prefix [ self fail: ' ' rule: #s_flow_line_prefix. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_indent [ | s_indent p | @@ -1210,7 +1224,7 @@ PPYAMLGrammarTest >> test_s_indent [ 'a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_indent_smaller [ | s_indent p | @@ -1229,7 +1243,7 @@ PPYAMLGrammarTest >> test_s_indent_smaller [ ' a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_collection [ context YAMLContext: #'block-in'. @@ -1260,7 +1274,7 @@ mapping: ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_in_block [ context YAMLContext: #'block-in'. @@ -1284,7 +1298,7 @@ PPYAMLGrammarTest >> test_s_l_block_in_block [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_indented [ context YAMLContext: #'block-in'. context YAMLM: 1. @@ -1315,7 +1329,7 @@ PPYAMLGrammarTest >> test_s_l_block_indented [ self assert: result second = 'bar'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_indented_sequence [ context YAMLContext: #'block-in'. context YAMLM: 3. @@ -1363,7 +1377,7 @@ PPYAMLGrammarTest >> test_s_l_block_indented_sequence [ - bar' rule: #s_l_block_indented. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_node [ context YAMLContext: #'block-in'. context YAMLN: -1. @@ -1393,7 +1407,7 @@ folded: self assert: (result at: 'folded') = 'value'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_flow_in_block [ context YAMLN: 3. @@ -1404,13 +1418,13 @@ PPYAMLGrammarTest >> test_s_l_flow_in_block [ self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_nb_spaced_text [ self parse: ' * bullet' rule: #s_nb_spaced_text. self assert: result = ' * bullet'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_ns_plain_next_line [ self parse: ' abc' rule: #s_ns_plain_next_line. @@ -1423,14 +1437,14 @@ PPYAMLGrammarTest >> test_s_ns_plain_next_line [ abc'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate [ self parse: ' ' rule: #s_separate. self parse: ' ' rule: #s_separate. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate_in_line [ self parse: ' ' rule: #s_separate_in_line. self assert: result = ' '. @@ -1438,7 +1452,7 @@ PPYAMLGrammarTest >> test_s_separate_in_line [ self assert: result = ' '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate_lines [ self parse: ' ' rule: #s_separate_lines. self parse: ' ' rule: #s_separate_lines. diff --git a/src/PetitYAML-Tests/package.st b/src/PetitYAML-Tests/package.st index 0908b61..5edbd19 100644 --- a/src/PetitYAML-Tests/package.st +++ b/src/PetitYAML-Tests/package.st @@ -1 +1 @@ -Package { #name : #'PetitYAML-Tests' } +Package { #name : 'PetitYAML-Tests' } diff --git a/src/PetitYAML/PPContext.extension.st b/src/PetitYAML/PPContext.extension.st index ffb7f89..fb9c6e4 100644 --- a/src/PetitYAML/PPContext.extension.st +++ b/src/PetitYAML/PPContext.extension.st @@ -1,42 +1,42 @@ -Extension { #name : #PPContext } +Extension { #name : 'PPContext' } -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLChomp [ ^ self propertyAt: #YAMLChomp ifAbsent: #'keep' ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLChomp: whatever [ self propertyAt: #YAMLChomp put: whatever ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLContext [ ^ self propertyAt: #YAMLContext ifAbsent: #'flow-in' ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLContext: whatever [ self propertyAt: #YAMLContext put: whatever ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLM [ ^ self propertyAt: #YAMLM ifAbsent: [ ^ 1 ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLM: whatever [ self propertyAt: #YAMLM put: whatever ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLN [ self indentStack isEmpty ifTrue: [ ^ 1 ]. ^ self indentStack top column ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLN: whatever [ | compare | compare := PPCompareParser @@ -47,12 +47,12 @@ PPContext >> YAMLN: whatever [ self indentStack push: compare. ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLRestoreM [ ^ self indentTraces pop: #YAMLM ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPContext >> YAMLRestoreN [ ^ self indentStack pop ] diff --git a/src/PetitYAML/PPParser.extension.st b/src/PetitYAML/PPParser.extension.st index c61efed..a9497bf 100644 --- a/src/PetitYAML/PPParser.extension.st +++ b/src/PetitYAML/PPParser.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #PPParser } +Extension { #name : 'PPParser' } -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLBlockIn [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -14,7 +14,7 @@ PPParser >> YAMLBlockIn [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLBlockKey [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -28,7 +28,7 @@ PPParser >> YAMLBlockKey [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLBlockOut [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -42,7 +42,7 @@ PPParser >> YAMLBlockOut [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLFlowIn [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -56,7 +56,7 @@ PPParser >> YAMLFlowIn [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLFlowKey [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -70,7 +70,7 @@ PPParser >> YAMLFlowKey [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLFlowOut [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -84,7 +84,7 @@ PPParser >> YAMLFlowOut [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLM [ ^ self >=> [:context :cc | | retval | @@ -97,7 +97,7 @@ PPParser >> YAMLM [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLNPlus [ ^ self >=> [:context :cc | | retval lastIndent | @@ -111,7 +111,7 @@ PPParser >> YAMLNPlus [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLPlusM [ ^ self >=> [:context :cc | | retval lastIndent | @@ -125,7 +125,7 @@ PPParser >> YAMLPlusM [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLSeqSpaces [ ^ self >=> [:context :cc | | retval lastIndent | @@ -144,7 +144,7 @@ PPParser >> YAMLSeqSpaces [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> YAMLinFlow [ ^ self >=> [:context :cc | | retval aYAMLContext | @@ -161,7 +161,7 @@ PPParser >> YAMLinFlow [ ] ] -{ #category : #'*PetitYAML' } +{ #category : '*PetitYAML' } PPParser >> preceeds [ ^ self >=> [ :context :cc | | memento result | diff --git a/src/PetitYAML/PPYAMLGrammar.class.st b/src/PetitYAML/PPYAMLGrammar.class.st index 7654a12..26cdcd0 100644 --- a/src/PetitYAML/PPYAMLGrammar.class.st +++ b/src/PetitYAML/PPYAMLGrammar.class.st @@ -16,8 +16,8 @@ Properties are not yet supported. " Class { - #name : #PPYAMLGrammar, - #superclass : #PPCompositeParser, + #name : 'PPYAMLGrammar', + #superclass : 'PPCompositeParser', #instVars : [ 's_indent', 's_block_line_prefix', @@ -138,12 +138,23 @@ Class { 'l_block_sequence', 'l_block_mapping', 'l_bare_document', - 'aligns' + 'aligns', + 'c_single_quoted', + 'nb_single_char', + 'ns_single_char', + 's_single_escaped', + 'nb_single_text', + 's_single_break', + 'nb_ns_single_in_line', + 's_single_next_line', + 'nb_single_multi_line', + 'nb_single_one_line' ], - #category : #PetitYAML + #category : 'PetitYAML', + #package : 'PetitYAML' } -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> aligns [ ^ [ :context | context indentStack isEmpty ifFalse: [ @@ -151,12 +162,12 @@ PPYAMLGrammar >> aligns [ ] asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> autoDetect: context [ ^ self autoDetect: context blockHeader: false ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> autoDetect: context blockHeader: blockHeader [ | retval position | position := context position. @@ -185,27 +196,27 @@ PPYAMLGrammar >> autoDetect: context blockHeader: blockHeader [ ^ retval ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_as_line_feed [ ^ b_break ==> [ :e | String cr ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_as_space [ ^ b_break ==> [ :e | String space ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_break [ ^ #newline asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_char [ ^ Character cr asParser / Character lf asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_chomped_last [ ^ ((b_non_content / #eof asParser) if: [ :context | context YAMLChomp = #strip ]) / @@ -213,17 +224,17 @@ PPYAMLGrammar >> b_chomped_last [ ((b_as_line_feed / #eof asParser) if: [ :context | context YAMLChomp = #keep ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_comment [ ^ b_non_content / #eof asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_l_folded [ ^ b_l_trimmed / b_as_space ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_l_spaced [ ^ b_as_line_feed, l_empty YAMLBlockIn star @@ -236,7 +247,7 @@ PPYAMLGrammar >> b_l_spaced [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_l_trimmed [ ^ (b_non_content, l_empty plus) @@ -246,7 +257,7 @@ PPYAMLGrammar >> b_l_trimmed [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_nb_literal_next [ ^ b_as_line_feed, l_nb_literal_text map: [ :lf :text | @@ -254,26 +265,26 @@ PPYAMLGrammar >> b_nb_literal_next [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> b_non_content [ ^ b_break ==> [ :e | '' ]. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_b_block_header [ ^ ((c_indentation_indicator, c_chomping_indicator) / (c_chomping_indicator, c_indentation_indicator)), s_b_comment ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_chomping_indicator [ ^ ($- asParser, [ :context | context YAMLChomp: #strip. #strip ] asParser) / ($+ asParser, [ :context | context YAMLChomp: #keep. #keep ] asParser) / (nil asParser, [ :context | context YAMLChomp: #clip. #clip ] asParser) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_double_quoted [ ^ ($" asParser, nb_double_text, $" asParser) map: [ :first :text :second | "first asString, text, second asString" @@ -281,7 +292,7 @@ PPYAMLGrammar >> c_double_quoted [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_flow_indicator [ ^ $, asParser / $[ asParser / @@ -290,20 +301,20 @@ PPYAMLGrammar >> c_flow_indicator [ $} asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_flow_json_content [ ^ c_flow_sequence / c_flow_mapping / - "c_single_quoted /" + c_single_quoted / c_double_quoted ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_flow_json_node [ ^ ( c_ns_properties, s_separate optional) optional, c_flow_json_content ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_flow_mapping [ ^ ${ asParser, s_separate optional, ns_s_flow_map_entries YAMLinFlow optional, $} asParser @@ -315,7 +326,7 @@ PPYAMLGrammar >> c_flow_mapping [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_flow_sequence [ ^ $[ asParser, s_separate optional, ns_s_flow_seq_entries YAMLinFlow optional, $] asParser @@ -324,7 +335,7 @@ PPYAMLGrammar >> c_flow_sequence [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_indentation_indicator [ ^ #digit asParser >=> [ :context :cc | | digit | @@ -339,7 +350,7 @@ PPYAMLGrammar >> c_indentation_indicator [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_indicator [ ^ $- asParser / $? asParser / @@ -362,7 +373,7 @@ PPYAMLGrammar >> c_indicator [ $` asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_block_map_explicit_entry [ ^ c_l_block_map_explicit_key, (l_block_map_explicit_value / e_node) @@ -371,24 +382,24 @@ PPYAMLGrammar >> c_l_block_map_explicit_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_block_map_explicit_key [ ^ $? asParser, s_l_block_indented YAMLBlockOut ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_block_map_implicit_value [ ^ $: asParser, (s_l_block_node YAMLBlockOut / ((e_node, s_l_comments) ==> #first)) ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_block_seq_entry [ ^ ($- asParser, ns_char not), s_l_block_indented YAMLBlockIn"(n,block_in)" ==> #last ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_folded [ ^ $> asParser, c_b_block_header, (l_folded_content >=> [ :context :cc | | retval | @@ -399,7 +410,7 @@ PPYAMLGrammar >> c_l_folded [ ]) ==> #third ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_l_literal [ ^ ($| asParser, c_b_block_header, (l_literal_content >=> [ :context :cc | | retval | @@ -412,17 +423,17 @@ PPYAMLGrammar >> c_l_literal [ ])) ==> #third ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_nb_comment_text [ ^ $# asParser, nb_char star ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_flow_map_adjacent_value [ ^ $: asParser, ( ( s_separate optional, ns_flow_node ==> #second) / e_node ) "Value" ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_flow_map_empty_key_entry [ ^ e_node "Key", c_ns_flow_map_separate_value map: [ :key :sep | @@ -430,7 +441,7 @@ PPYAMLGrammar >> c_ns_flow_map_empty_key_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_flow_map_json_key_entry [ ^ c_flow_json_node, ( (s_separate optional, c_ns_flow_map_adjacent_value) ==> #second / e_node) @@ -439,45 +450,53 @@ PPYAMLGrammar >> c_ns_flow_map_json_key_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_flow_map_separate_value [ ^ $: asParser, ns_plain_safe not, (( s_separate, ns_flow_node ==> #second ) / e_node "Value" ) ==> #third ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_flow_pair_json_key_entry [ ^ c_s_implicit_json_key YAMLFlowKey, c_ns_flow_map_adjacent_value ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_ns_properties [ ^ PPFailingParser message: 'Properties not YET supported' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_printable [ ^ PPPredicateObjectParser on: (PPCharSetPredicate on: [ :e | e asInteger >= 32 or: [ e isSeparator ] ]) message: 'c_printable expected' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> c_s_implicit_json_key [ ^ c_flow_json_node, s_separate_in_line optional ==> #first ] -{ #category : #spec } +{ #category : 'spec' } +PPYAMLGrammar >> c_single_quoted [ + ^ ($' asParser, nb_single_text, $' asParser) map: [ :first :text :second | + "first asString, text, second asString" + text + ] +] + +{ #category : 'spec' } PPYAMLGrammar >> e_node [ ^ e_scalar ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> e_scalar [ ^ nil asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_bare_document [ ^ s_l_block_node "(-1,block_in)" >=> [ :context :cc | @@ -493,12 +512,12 @@ PPYAMLGrammar >> l_bare_document [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_block_map_explicit_value [ ^ s_indent, $: asParser, s_l_block_indented YAMLBlockOut ==> #third ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_block_mapping [ ^ (( s_indent"(n+m)", ns_l_block_map_entry"(n+m) ") plus "/* For some fixed auto_detected m > 0 */ " @@ -521,7 +540,7 @@ PPYAMLGrammar >> l_block_mapping [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_block_sequence [ ^ ( s_indent "(n+m)", c_l_block_seq_entry"(n+m)" ==> #second) plus "/* For some fixed auto_detected m > 0 */ " @@ -537,7 +556,7 @@ PPYAMLGrammar >> l_block_sequence [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_chomped_empty [ ^ (l_strip_empty if: [ :context | context YAMLChomp = #strip ]) / @@ -545,14 +564,14 @@ PPYAMLGrammar >> l_chomped_empty [ (l_keep_empty if: [ :context | context YAMLChomp = #keep ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_comment [ ^ (#startOfLine asParser, #eof asParser) not, "if the line is last and empty, do not consume it" s_separate_in_line, c_nb_comment_text optional, b_comment ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_empty [ ^ ( s_line_prefix / s_indent_smaller), @@ -562,7 +581,7 @@ PPYAMLGrammar >> l_empty [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_folded_content [ ^ (l_nb_diff_lines, b_chomped_last) optional, l_chomped_empty @@ -582,7 +601,7 @@ PPYAMLGrammar >> l_folded_content [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_keep_empty [ ^ l_empty YAMLBlockIn star, l_trail_comments optional @@ -591,7 +610,7 @@ PPYAMLGrammar >> l_keep_empty [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_literal_content [ ^ (l_nb_literal_text, b_nb_literal_next star, b_chomped_last) optional, l_chomped_empty @@ -612,7 +631,7 @@ PPYAMLGrammar >> l_literal_content [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_nb_diff_lines [ ^ l_nb_same_lines, (b_as_line_feed, l_nb_same_lines) star @@ -627,7 +646,7 @@ PPYAMLGrammar >> l_nb_diff_lines [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_nb_folded_lines [ ^ s_nb_folded_text, (b_l_folded YAMLBlockIn, s_nb_folded_text) star @@ -643,7 +662,7 @@ PPYAMLGrammar >> l_nb_folded_lines [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_nb_literal_text [ ^ ((l_empty YAMLBlockIn) star, s_indent, nb_char plus flatten) @@ -658,7 +677,7 @@ PPYAMLGrammar >> l_nb_literal_text [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_nb_same_lines [ ^ l_empty YAMLBlockIn star, (l_nb_folded_lines / l_nb_spaced_lines) @@ -671,7 +690,7 @@ PPYAMLGrammar >> l_nb_same_lines [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_nb_spaced_lines [ ^ s_nb_spaced_text, (b_l_spaced, s_nb_spaced_text) star @@ -688,28 +707,28 @@ PPYAMLGrammar >> l_nb_spaced_lines [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_strip_empty [ ^ (s_indent / s_indent_smaller, b_non_content ) star, l_trail_comments optional map: [:nonContent :comments | '' ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> l_trail_comments [ ^ s_indent_smaller, c_nb_comment_text, b_comment, l_comment star ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_char [ ^ b_char not, c_printable ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_double_char [ ^ ($/ asParser not, $" asParser not), nb_json ==> #third ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_double_multi_line [ ^ nb_ns_double_in_line, (s_double_next_line / (s_white star flatten)) @@ -718,12 +737,12 @@ PPYAMLGrammar >> nb_double_multi_line [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_double_one_line [ ^ nb_double_char star flatten ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_double_text [ ^ (nb_double_multi_line if: [:context | context YAMLContext = #'flow-out' ]) / @@ -732,38 +751,71 @@ PPYAMLGrammar >> nb_double_text [ (nb_double_one_line if: [:context | context YAMLContext = #'flow-key' ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_json [ ^ PPPredicateObjectParser on: (PPCharSetPredicate on: [ :e | e asInteger >= 32 or: [ e = Character tab ] ]) message: 'nb_json expected' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_ns_double_in_line [ ^ ( s_white star, ns_double_char) star flatten ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> nb_ns_plain_in_line [ ^ (s_white star, ns_plain_char) star flatten ] -{ #category : #spec } +{ #category : 'spec' } +PPYAMLGrammar >> nb_ns_single_in_line [ + ^ ( s_white star, ns_single_char) star flatten +] + +{ #category : 'spec' } +PPYAMLGrammar >> nb_single_char [ + ^ ($/ asParser not, $' asParser not), nb_json ==> #third +] + +{ #category : 'spec' } +PPYAMLGrammar >> nb_single_multi_line [ + ^ nb_ns_single_in_line, (s_single_next_line / (s_white star flatten)) + + map: [ :first :rest | + first, rest + ] +] + +{ #category : 'spec' } +PPYAMLGrammar >> nb_single_one_line [ + ^ nb_single_char star flatten +] + +{ #category : 'spec' } +PPYAMLGrammar >> nb_single_text [ + ^ + (nb_single_multi_line if: [:context | context YAMLContext = #'flow-out' ]) / + (nb_single_multi_line if: [:context | context YAMLContext = #'flow-in' ]) / + (nb_single_one_line if: [:context | context YAMLContext = #'block-key' ]) / + (nb_single_one_line if: [:context | context YAMLContext = #'flow-key' ]) +] + +{ #category : 'spec' } PPYAMLGrammar >> ns_char [ ^ s_white not, nb_char ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_double_char [ ^ s_white not, nb_double_char ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_content [ ^ ns_flow_yaml_content / c_flow_json_content ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_map_entry [ " TODO JK: s_separate is optional, even though doc say, it is not. @@ -773,21 +825,21 @@ PPYAMLGrammar >> ns_flow_map_entry [ ns_flow_map_implicit_entry ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_map_explicit_entry [ ^ ns_flow_map_implicit_entry / (( e_node, e_node ) map: [ :key :value | key -> value ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_map_implicit_entry [ ^ ns_flow_map_yaml_key_entry / c_ns_flow_map_empty_key_entry / c_ns_flow_map_json_key_entry ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_map_yaml_key_entry [ ^ ns_flow_yaml_node, ((s_separate optional, c_ns_flow_map_separate_value) ==> #second / e_node) map: [ :key :value | @@ -795,14 +847,14 @@ PPYAMLGrammar >> ns_flow_map_yaml_key_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_node [ ^ "c_ns_alias_node /" ns_flow_content "/ ( c_ns_properties(n,c) ,( ( s_separate(n,c), ns_flow_content(n,c) ) / e_scalar ) ) " ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_pair [ ^ ($? asParser, s_separate, ns_flow_map_explicit_entry ==> #third) / ns_flow_pair_entry @@ -812,7 +864,7 @@ PPYAMLGrammar >> ns_flow_pair [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_pair_entry [ ^ ns_flow_pair_yaml_key_entry / c_ns_flow_map_empty_key_entry / @@ -820,7 +872,7 @@ PPYAMLGrammar >> ns_flow_pair_entry [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_pair_yaml_key_entry [ ^ ns_s_implicit_yaml_key YAMLFlowKey, c_ns_flow_map_separate_value @@ -830,30 +882,30 @@ PPYAMLGrammar >> ns_flow_pair_yaml_key_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_seq_entry [ ^ ns_flow_pair / ns_flow_node ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_yaml_content [ ^ ns_plain ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_flow_yaml_node [ ^ "c_ns_alias_node /" ns_flow_yaml_content "/ (c_ns_properties, ( ( s_separate(n,c), ns_flow_yaml_content(n,c) ) / e_scalar ) ) " ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_l_block_map_entry [ ^ c_l_block_map_explicit_entry / ns_l_block_map_implicit_entry ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_l_block_map_implicit_entry [ ^ ( ns_s_block_map_implicit_key / e_node ), c_l_block_map_implicit_value map: [ :key :value | @@ -861,7 +913,7 @@ PPYAMLGrammar >> ns_l_block_map_implicit_entry [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_l_compact_mapping [ ^ ns_l_block_map_entry, (s_indent, ns_l_block_map_entry ==> #second) star map: [ :entry :rest | @@ -873,7 +925,7 @@ PPYAMLGrammar >> ns_l_compact_mapping [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_l_compact_sequence [ ^ c_l_block_seq_entry, (s_indent, c_l_block_seq_entry ==> #second) star map: [ :first :rest | @@ -881,7 +933,7 @@ PPYAMLGrammar >> ns_l_compact_sequence [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain [ ^ (ns_plain_multi_line if: [: context | context YAMLContext = #'flow-out' ]) / @@ -890,20 +942,20 @@ PPYAMLGrammar >> ns_plain [ (ns_plain_one_line if: [: context | context YAMLContext = #'flow-key' ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_char [ ^ (($: asParser not, $# asParser not, ns_plain_safe) ==> #third) / ( ns_char preceeds, $# asParser) / (( $: asParser, ns_plain_safe and) ==> #first) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_first [ ^ (c_indicator not, ns_char) / (($? asParser / $: asParser / $- asParser), ns_plain_safe and ) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_multi_line [ ^ ns_plain_one_line, s_ns_plain_next_line star @@ -916,12 +968,12 @@ PPYAMLGrammar >> ns_plain_multi_line [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_one_line [ ^ (ns_plain_first, nb_ns_plain_in_line) flatten ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_safe [ ^ (ns_plain_safe_out if: [ :context | context YAMLContext = #'flow-out' ]) / @@ -930,23 +982,23 @@ PPYAMLGrammar >> ns_plain_safe [ (ns_plain_safe_in if: [ :context | context YAMLContext = #'flow-key' ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_safe_in [ ^ c_flow_indicator not, ns_char ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_plain_safe_out [ ^ ns_char ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_s_block_map_implicit_key [ ^ c_s_implicit_json_key YAMLBlockKey / ns_s_implicit_yaml_key YAMLBlockKey ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_s_flow_map_entries [ ^ ns_flow_map_entry, s_separate optional, ($, asParser, s_separate optional, ns_s_flow_map_entries optional) optional @@ -965,7 +1017,7 @@ PPYAMLGrammar >> ns_s_flow_map_entries [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_s_flow_seq_entries [ ^ ns_flow_seq_entry, s_separate optional, ( $, asParser, s_separate optional, ns_s_flow_seq_entries optional ) optional @@ -984,32 +1036,37 @@ PPYAMLGrammar >> ns_s_flow_seq_entries [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> ns_s_implicit_yaml_key [ ^ ns_flow_yaml_node, s_separate_in_line optional ==> #first ] -{ #category : #spec } +{ #category : 'spec' } +PPYAMLGrammar >> ns_single_char [ + ^ s_white not, nb_single_char ==> #second +] + +{ #category : 'spec' } PPYAMLGrammar >> s_b_comment [ ^ ( s_separate_in_line, c_nb_comment_text optional ) optional, b_comment ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_block_line_prefix [ ^ s_indent ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_double_break [ ^ s_flow_folded / s_double_escaped ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_double_escaped [ ^ PPFailingParser message: 's_double_escaped not yet implemented' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_double_next_line [ ^ s_double_break, ( ns_double_char, nb_ns_double_in_line, (s_double_next_line / (s_white star flatten))) optional @@ -1028,14 +1085,14 @@ PPYAMLGrammar >> s_double_next_line [ ]. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_flow_folded [ ^ s_separate_in_line optional, b_l_folded YAMLFlowIn "(n,flow-in)", s_flow_line_prefix "(n)" ==> #second ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_flow_line_prefix [ ^ s_indent, s_separate_in_line optional map: [ :indent :separate | @@ -1048,7 +1105,7 @@ PPYAMLGrammar >> s_flow_line_prefix [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_indent [ ^ (aligns not, s_space) star, aligns ==> [ :e | '' ] @@ -1058,7 +1115,7 @@ PPYAMLGrammar >> s_indent [ ==> [ :e | '' ]" ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_indent_smaller [ ^ (aligns not, s_space) star ==> [ :e | '' ] @@ -1068,7 +1125,7 @@ PPYAMLGrammar >> s_indent_smaller [ ==> [ :e | '' ]" ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_block_collection [ ^ ( s_separate YAMLNPlus, c_ns_properties YAMLNPlus ) optional, s_l_comments, ( l_block_sequence YAMLSeqSpaces / l_block_mapping ) @@ -1078,12 +1135,12 @@ PPYAMLGrammar >> s_l_block_collection [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_block_in_block [ ^ s_l_block_scalar / s_l_block_collection ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_block_indented [ "I did the hack here, because yaml's indent is n*space, mine is connected to the column" @@ -1095,12 +1152,12 @@ PPYAMLGrammar >> s_l_block_indented [ (( e_node, s_l_comments ) ==> #first) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_block_node [ ^ s_l_block_in_block / s_l_flow_in_block ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_block_scalar [ ^ s_separate YAMLNPlus"(n+1,c)", (c_ns_properties YAMLNPlus "(n+1,c)", s_separate YAMLNPlus "(n+1,c)" ) optional, @@ -1110,12 +1167,12 @@ PPYAMLGrammar >> s_l_block_scalar [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_comments [ ^ (s_b_comment / #startOfLine asParser), l_comment star ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_l_flow_in_block [ ^ s_separate YAMLNPlus YAMLFlowOut "(n+1,flow_out)", ns_flow_node YAMLNPlus YAMLFlowOut "(n+1,flow_out)", @@ -1126,7 +1183,7 @@ PPYAMLGrammar >> s_l_flow_in_block [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_line_prefix [ ^ (s_block_line_prefix if: [ :context | context YAMLContext = #'block-out' ]) / @@ -1135,7 +1192,7 @@ PPYAMLGrammar >> s_line_prefix [ (s_flow_line_prefix if: [ :context | context YAMLContext = #'flow-in' ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_nb_folded_text [ ^ s_indent, ns_char, nb_char star flatten @@ -1144,7 +1201,7 @@ PPYAMLGrammar >> s_nb_folded_text [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_nb_spaced_text [ ^ s_indent, s_white, nb_char star flatten @@ -1153,7 +1210,7 @@ PPYAMLGrammar >> s_nb_spaced_text [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_ns_plain_next_line [ ^ s_flow_folded, ns_plain_char, nb_ns_plain_in_line @@ -1162,7 +1219,7 @@ PPYAMLGrammar >> s_ns_plain_next_line [ ] ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_separate [ ^ (s_separate_lines if: [ :context | context YAMLContext = #'block-out' ]) / @@ -1174,33 +1231,62 @@ PPYAMLGrammar >> s_separate [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_separate_in_line [ ^ #blank asParser plus flatten / (#startOfLine asParser ==> [ :e | '' ]) ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_separate_lines [ ^ ( s_l_comments, s_flow_line_prefix) / s_separate_in_line ] -{ #category : #spec } +{ #category : 'spec' } +PPYAMLGrammar >> s_single_break [ + ^ s_flow_folded / s_single_escaped +] + +{ #category : 'spec' } +PPYAMLGrammar >> s_single_escaped [ + ^ PPFailingParser message: 's_singlw_escaped not yet implemented' +] + +{ #category : 'spec' } +PPYAMLGrammar >> s_single_next_line [ + ^ s_single_break, ( ns_single_char, nb_ns_single_in_line, + (s_single_next_line / (s_white star flatten))) optional + + map: [ :break :rest | + | retval | + retval := break. + rest ifNotNil: [ + retval := retval, rest first asString. + retval := retval, rest second. + rest third ifNotNil: [ + retval := retval, rest third. + ]. + retval + ] + ]. +] + +{ #category : 'spec' } PPYAMLGrammar >> s_space [ ^ Character space asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_tab [ ^ Character tab asParser ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammar >> s_white [ ^ s_space / s_tab ] -{ #category : #accessing } +{ #category : 'accessing' } PPYAMLGrammar >> start [ ^ l_bare_document ] diff --git a/src/PetitYAML/PPYAMLGrammarTest.class.st b/src/PetitYAML/PPYAMLGrammarTest.class.st index 526d5ad..ff3d514 100644 --- a/src/PetitYAML/PPYAMLGrammarTest.class.st +++ b/src/PetitYAML/PPYAMLGrammarTest.class.st @@ -1,18 +1,19 @@ Class { - #name : #PPYAMLGrammarTest, - #superclass : #PPCompositeParserTest, + #name : 'PPYAMLGrammarTest', + #superclass : 'PPCompositeParserTest', #instVars : [ 'context' ], - #category : #PetitYAML + #category : 'PetitYAML', + #package : 'PetitYAML' } -{ #category : #accessing } +{ #category : 'accessing' } PPYAMLGrammarTest >> context [ ^ context ] -{ #category : #parsing } +{ #category : 'parsing' } PPYAMLGrammarTest >> debug: aString rule: aSymbol [ | production | production := self parserInstanceFor: aSymbol. @@ -26,18 +27,18 @@ PPYAMLGrammarTest >> debug: aString rule: aSymbol [ ^ result ] -{ #category : #accessing } +{ #category : 'accessing' } PPYAMLGrammarTest >> parserClass [ ^ PPYAMLGrammar ] -{ #category : #running } +{ #category : 'running' } PPYAMLGrammarTest >> setUp [ super setUp. context := PPContext new. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument [ | string | string :='receipt: Oz-Ware Purchase Invoice'. @@ -47,7 +48,7 @@ PPYAMLGrammarTest >> testDocument [ self assert: (result at: 'receipt') = 'Oz-Ware Purchase Invoice' ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument1 [ | string | string :='receipt: Oz-Ware Purchase Invoice @@ -76,7 +77,7 @@ items: ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testDocument2 [ | string | string :='receipt: Oz-Ware Purchase Invoice @@ -90,7 +91,7 @@ customer: self assert: ((result at: 'customer') at: #family) = 'Gale' ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testMappingClipStripKeep [ | string | @@ -112,7 +113,7 @@ keep: |+ self assert: (result at: 'keep') = String cr. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testSequence [ | string | context YAMLN: 1. @@ -127,7 +128,7 @@ PPYAMLGrammarTest >> testSequence [ self assert: (result first at: 'three') = 'four'. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testSequence2 [ | string | string := @@ -141,7 +142,7 @@ PPYAMLGrammarTest >> testSequence2 [ self assert: result size = 4. ] -{ #category : #'tests - complex' } +{ #category : 'tests - complex' } PPYAMLGrammarTest >> testTravisYml [ | string | string :='language: c @@ -269,7 +270,7 @@ deploy: ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_chomped_last [ context YAMLChomp: #'strip'. self parse: ' @@ -287,7 +288,7 @@ PPYAMLGrammarTest >> test_b_chomped_last [ self assert: result = String cr. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_l_folded [ self parse: ' ' rule: #b_l_folded. @@ -306,7 +307,7 @@ PPYAMLGrammarTest >> test_b_l_folded [ self assert: result = (String cr, String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_l_trimmed [ self parse: ' @@ -321,7 +322,7 @@ PPYAMLGrammarTest >> test_b_l_trimmed [ self assert: result = (String cr, String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_b_nb_literal_next [ context YAMLContext: #'block-in'. context YAMLN: 3. @@ -337,7 +338,7 @@ PPYAMLGrammarTest >> test_b_nb_literal_next [ self assert: result = (String cr, String cr, ' abc'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_double_qouted [ self parse: '"hi there"' rule: #c_double_quoted. self assert: result = 'hi there'. @@ -350,13 +351,13 @@ PPYAMLGrammarTest >> test_c_double_qouted [ 2nd non-empty 3rd non-empty ' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_json_content [ self parse: '"a"' rule: #c_flow_json_content. self assert: result = 'a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_mapping [ self parse: '{ one : two , three: four , }' rule: #c_flow_mapping. self assert: result size = 2. @@ -397,7 +398,7 @@ omitted value:, ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_flow_sequence [ self parse: '[three ,four, five]' rule: #c_flow_sequence. self assert: result size = 3. @@ -436,7 +437,7 @@ foo: bar self assert: result second = 'b' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_entry [ context YAMLN: 1. context YAMLM: 1. @@ -459,7 +460,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_entry [ self assert: result value second = 'two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_key [ context YAMLN: 1. context YAMLM: 1. @@ -475,7 +476,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_key [ self assert: result = ('block key', String cr). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_explicit_value [ context YAMLN: 1. context YAMLM: 1. @@ -490,7 +491,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_explicit_value [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_map_implict_value [ context YAMLContext: #'block-in'. self parse: ': in-line value' rule: #c_l_block_map_implicit_value. @@ -510,7 +511,7 @@ PPYAMLGrammarTest >> test_c_l_block_map_implict_value [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_block_sequence_entry [ context YAMLContext: #'block-in'. context YAMLM: 1. @@ -526,7 +527,7 @@ PPYAMLGrammarTest >> test_c_l_block_sequence_entry [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_folded [ self parse: '> folded @@ -564,7 +565,7 @@ last line '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal [ self parse: '| literal @@ -593,7 +594,7 @@ text ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_chomping [ self parse: '|- text @@ -617,7 +618,7 @@ PPYAMLGrammarTest >> test_c_l_literal_chomping [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_failures [ context YAMLContext: #'block-in'. "Should fail, but it does not, probably have to add some functionality to auto-detect" @@ -635,7 +636,7 @@ PPYAMLGrammarTest >> test_c_l_literal_failures [ text' rule: #c_l_literal. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_c_l_literal_strip [ self parse: '|- # text @@ -647,7 +648,7 @@ PPYAMLGrammarTest >> test_c_l_literal_strip [ self assert: result = '# text' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_block_mapping [ context YAMLN: -1. context YAMLContext: #'block-in'. @@ -685,7 +686,7 @@ PPYAMLGrammarTest >> test_l_block_mapping [ self assert: (result at: 'quoted key') first = 'entry'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_block_sequence [ context YAMLContext: #'block-in'. self parse: ' - foo @@ -719,19 +720,19 @@ PPYAMLGrammarTest >> test_l_block_sequence [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_comment [ self parse: ' # whatever' rule: #l_comment. self fail: '' rule: #l_comment. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty [ self test_l_empty_blockIn. self test_l_empty_flowIn. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty_blockIn [ context YAMLContext: #'block-in'. context YAMLN: 3. @@ -748,7 +749,7 @@ PPYAMLGrammarTest >> test_l_empty_blockIn [ ' rule: #l_empty. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_empty_flowIn [ context YAMLContext: #'flow-in'. context YAMLN: 3. @@ -763,14 +764,14 @@ PPYAMLGrammarTest >> test_l_empty_flowIn [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_keep_empty [ self parse: ' ' rule: #l_keep_empty. self assert: result = String cr. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text [ context YAMLN: 3. context YAMLContext: #'block-in'. @@ -800,7 +801,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text [ self assert: result = (String cr, String cr, 'literal'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text_failures [ context YAMLN: 3. context YAMLContext: #'block-in'. @@ -813,7 +814,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text_failures [ abc' rule: #l_nb_literal_text. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_literal_text_flowIn [ context YAMLN: 3. context YAMLContext: #'flow-in'. @@ -826,7 +827,7 @@ PPYAMLGrammarTest >> test_l_nb_literal_text_flowIn [ self assert: result = (String cr, ' '). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_l_nb_spaced_lines [ self parse: ' * bullet @@ -835,7 +836,7 @@ PPYAMLGrammarTest >> test_l_nb_spaced_lines [ "TODO JK: add asserts" ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_multi_line [ self parse: 'hi there' rule: #nb_double_multi_line. self assert: result = 'hi there'. @@ -852,34 +853,34 @@ PPYAMLGrammarTest >> test_nb_double_multi_line [ 2nd non-empty 3rd non-empty ' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_one_line [ self parse: 'hi there' rule: #nb_double_one_line. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_qouted [ self parse: '"hi there"' rule: #c_double_quoted. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_double_text [ self parse: 'hi there' rule: #nb_double_text. self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_json [ self parse: ' ' rule: #nb_json. self parse: 'a' rule: #nb_json. self fail: String cr rule: #nb_json. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_nb_ns_double_in_line [ self parse: 'hi there' rule: #nb_ns_double_in_line. self assert: result = 'hi there'. @@ -891,7 +892,7 @@ PPYAMLGrammarTest >> test_nb_ns_double_in_line [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_entry [ self parse: '? explicit: entry' rule: #ns_flow_map_entry. self assert: result = ('explicit' -> 'entry'). @@ -903,7 +904,7 @@ PPYAMLGrammarTest >> test_ns_flow_map_entry [ self assert: result = ('implicit' -> 'entry'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_explicit_entry [ self parse: 'explicit: entry' rule: #ns_flow_map_explicit_entry. self assert: result = ('explicit' -> 'entry'). @@ -912,13 +913,13 @@ PPYAMLGrammarTest >> test_ns_flow_map_explicit_entry [ self assert: result = (nil -> nil). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_map_implicit_entry [ self parse: 'implicit: entry' rule: #ns_flow_map_implicit_entry. self assert: result = ('implicit' -> 'entry'). ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_node [ self parse: 'simple text' rule: #ns_flow_node. self assert: result = 'simple text'. @@ -939,7 +940,7 @@ PPYAMLGrammarTest >> test_ns_flow_node [ self assert: result size = 1. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_pair [ self parse: 'single: pair' rule: #ns_flow_pair. @@ -947,7 +948,7 @@ PPYAMLGrammarTest >> test_ns_flow_pair [ self assert: (result at: 'single') = 'pair'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_flow_seq_entry [ self parse: 'one' rule: #ns_flow_seq_entry. self assert: result = 'one'. @@ -956,7 +957,7 @@ PPYAMLGrammarTest >> test_ns_flow_seq_entry [ self assert: result = 'one two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_block_map_implicit_entry [ self parse: 'foo: bar' rule: #ns_l_block_map_implicit_entry. self assert: result key = 'foo'. @@ -990,7 +991,7 @@ PPYAMLGrammarTest >> test_ns_l_block_map_implicit_entry [ self assert: result value = nil. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_compact_mapping [ self parse: 'one: two # Compact mapping' rule: #ns_l_compact_mapping. self assert: result size = 1. @@ -1016,7 +1017,7 @@ three: four' rule: #ns_l_compact_mapping. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_l_compact_sequence [ self parse: '- one - two' rule: #ns_l_compact_sequence. @@ -1035,7 +1036,7 @@ PPYAMLGrammarTest >> test_ns_l_compact_sequence [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain [ context YAMLContext: #'flow-in'. self parse: 'a' rule: #ns_plain. @@ -1046,7 +1047,7 @@ PPYAMLGrammarTest >> test_ns_plain [ "NOT Complete assertions..." ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_char [ self parse: 'a' rule: #ns_plain_char. @@ -1054,7 +1055,7 @@ PPYAMLGrammarTest >> test_ns_plain_char [ self fail: ':' rule: #ns_plain_char. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_multi_line [ self parse: '1st non-empty @@ -1065,7 +1066,7 @@ PPYAMLGrammarTest >> test_ns_plain_multi_line [ 2nd non-empty 3rd non-empty' ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_one_line [ self parse: 'implicit block key' rule: #ns_plain_one_line. self assert: result = 'implicit block key'. @@ -1074,7 +1075,7 @@ PPYAMLGrammarTest >> test_ns_plain_one_line [ self assert: result = 'implicit:entry'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_safe_in [ self parse: 'a' rule: #ns_plain_safe_in. self parse: '+' rule: #ns_plain_safe_in. @@ -1089,7 +1090,7 @@ PPYAMLGrammarTest >> test_ns_plain_safe_in [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_plain_safe_out [ self parse: 'a' rule: #ns_plain_safe_out. self parse: '+' rule: #ns_plain_safe_out. @@ -1099,7 +1100,7 @@ PPYAMLGrammarTest >> test_ns_plain_safe_out [ self fail: String cr rule: #ns_plain_safe_out. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_s_flow_seq_entries [ self parse: 'one, two' rule: #ns_s_flow_seq_entries. @@ -1115,14 +1116,14 @@ PPYAMLGrammarTest >> test_ns_s_flow_seq_entries [ self assert: result second = 'two'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_ns_s_implicit_yaml_key [ self parse: 'single ' rule: #ns_s_implicit_yaml_key. self assert: result = 'single'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_block_line_prefix [ context YAMLN: 3. self parse: ' ' rule: #s_block_line_prefix. @@ -1133,7 +1134,7 @@ PPYAMLGrammarTest >> test_s_block_line_prefix [ self fail: ' ' rule: #s_block_line_prefix. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_double_next_line [ self parse: ' abc' rule: #s_double_next_line. @@ -1157,7 +1158,7 @@ abc def'. self assert: result = ' abc '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_flow_folded [ self parse: ' ' rule: #s_flow_folded. @@ -1172,7 +1173,7 @@ PPYAMLGrammarTest >> test_s_flow_folded [ self fail: '' rule: #s_flow_folded. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_flow_line_prefix [ context YAMLN: 3. self parse: ' ' rule: #s_flow_line_prefix. @@ -1187,7 +1188,7 @@ PPYAMLGrammarTest >> test_s_flow_line_prefix [ self fail: ' ' rule: #s_flow_line_prefix. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_indent [ | s_indent p | @@ -1210,7 +1211,7 @@ PPYAMLGrammarTest >> test_s_indent [ 'a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_indent_smaller [ | s_indent p | @@ -1229,7 +1230,7 @@ PPYAMLGrammarTest >> test_s_indent_smaller [ ' a'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_collection [ context YAMLContext: #'block-in'. @@ -1260,7 +1261,7 @@ mapping: ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_in_block [ context YAMLContext: #'block-in'. @@ -1284,7 +1285,7 @@ PPYAMLGrammarTest >> test_s_l_block_in_block [ ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_indented [ context YAMLContext: #'block-in'. context YAMLM: 1. @@ -1315,7 +1316,7 @@ PPYAMLGrammarTest >> test_s_l_block_indented [ self assert: result second = 'bar'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_indented_sequence [ context YAMLContext: #'block-in'. context YAMLM: 3. @@ -1363,7 +1364,7 @@ PPYAMLGrammarTest >> test_s_l_block_indented_sequence [ - bar' rule: #s_l_block_indented. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_block_node [ context YAMLContext: #'block-in'. context YAMLN: -1. @@ -1393,7 +1394,7 @@ folded: self assert: (result at: 'folded') = 'value'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_l_flow_in_block [ context YAMLN: 3. @@ -1404,13 +1405,13 @@ PPYAMLGrammarTest >> test_s_l_flow_in_block [ self assert: result = 'hi there'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_nb_spaced_text [ self parse: ' * bullet' rule: #s_nb_spaced_text. self assert: result = ' * bullet'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_ns_plain_next_line [ self parse: ' abc' rule: #s_ns_plain_next_line. @@ -1423,14 +1424,14 @@ PPYAMLGrammarTest >> test_s_ns_plain_next_line [ abc'. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate [ self parse: ' ' rule: #s_separate. self parse: ' ' rule: #s_separate. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate_in_line [ self parse: ' ' rule: #s_separate_in_line. self assert: result = ' '. @@ -1438,7 +1439,7 @@ PPYAMLGrammarTest >> test_s_separate_in_line [ self assert: result = ' '. ] -{ #category : #spec } +{ #category : 'spec' } PPYAMLGrammarTest >> test_s_separate_lines [ self parse: ' ' rule: #s_separate_lines. self parse: ' ' rule: #s_separate_lines. diff --git a/src/PetitYAML/package.st b/src/PetitYAML/package.st index b180d48..49efdcd 100644 --- a/src/PetitYAML/package.st +++ b/src/PetitYAML/package.st @@ -1 +1 @@ -Package { #name : #PetitYAML } +Package { #name : 'PetitYAML' }