Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
#format : #tonel,
#version: #'1.0'
}
5 changes: 3 additions & 2 deletions src/.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
#format : #tonel
}
#format : #tonel,
#version: #'1.0'
}
13 changes: 13 additions & 0 deletions src/PetitYAML-Tests/PPYAMLGrammarTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
89 changes: 87 additions & 2 deletions src/PetitYAML/PPYAMLGrammar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down