diff --git a/.properties b/.properties new file mode 100644 index 0000000..0957ed5 --- /dev/null +++ b/.properties @@ -0,0 +1,4 @@ +{ + #format : #tonel, + #version: #'1.0' +} diff --git a/src/.properties b/src/.properties index ad0471d..0957ed5 100644 --- a/src/.properties +++ b/src/.properties @@ -1,3 +1,4 @@ { - #format : #tonel -} \ No newline at end of file + #format : #tonel, + #version: #'1.0' +} diff --git a/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st b/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st index 7529d2a..cfbd4ea 100644 --- a/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st +++ b/src/PetitYAML-Tests/PPYAMLGrammarTest.class.st @@ -647,6 +647,19 @@ PPYAMLGrammarTest >> test_c_l_literal_strip [ self assert: result = '# text' ] +{ #category : #tests } +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. diff --git a/src/PetitYAML/PPYAMLGrammar.class.st b/src/PetitYAML/PPYAMLGrammar.class.st index 7654a12..197581e 100644 --- a/src/PetitYAML/PPYAMLGrammar.class.st +++ b/src/PetitYAML/PPYAMLGrammar.class.st @@ -138,7 +138,17 @@ Class { 'l_block_sequence', 'l_block_mapping', 'l_bare_document', - 'aligns' + 'aligns', + 's_single_escaped', + 'nb_single_text', + 'nb_single_multi_line', + 'nb_single_one_line', + 'nb_ns_single_in_line', + 's_single_next_line', + 'ns_single_char', + 'nb_single_char', + 's_single_break', + 'c_single_quoted' ], #category : #PetitYAML } @@ -294,7 +304,7 @@ PPYAMLGrammar >> c_flow_indicator [ PPYAMLGrammar >> c_flow_json_content [ ^ c_flow_sequence / c_flow_mapping / - "c_single_quoted /" + c_single_quoted / c_double_quoted ] @@ -467,6 +477,14 @@ PPYAMLGrammar >> c_s_implicit_json_key [ ^ c_flow_json_node, s_separate_in_line optional ==> #first ] +{ #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 @@ -748,6 +766,39 @@ PPYAMLGrammar >> nb_ns_plain_in_line [ ^ (s_white star, ns_plain_char) star flatten ] +{ #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 @@ -989,6 +1040,11 @@ PPYAMLGrammar >> ns_s_implicit_yaml_key [ ^ ns_flow_yaml_node, s_separate_in_line optional ==> #first ] +{ #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 @@ -1185,6 +1241,35 @@ PPYAMLGrammar >> s_separate_lines [ s_separate_in_line ] +{ #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