YamlReference 0.3 → 0.4
raw patch · 44 files changed
+232/−160 lines, 44 files
Files
- Text/Yaml/Reference.bnf +39/−36
- Text/Yaml/Reference.hs +24/−13
- YamlReference.cabal +24/−18
- tests/c-ns-properties.input +0/−1
- tests/c-ns-properties.invalid.input +0/−1
- tests/c-ns-properties.invalid.output +0/−3
- tests/c-ns-properties.n=0.c=block-out.input +1/−0
- tests/c-ns-properties.n=0.c=block-out.invalid.input +1/−0
- tests/c-ns-properties.n=0.c=block-out.invalid.output +3/−0
- tests/c-ns-properties.n=0.c=block-out.output +13/−0
- tests/c-ns-properties.n=0.c=flow-out.input +2/−0
- tests/c-ns-properties.n=0.c=flow-out.invalid.input +2/−0
- tests/c-ns-properties.n=0.c=flow-out.invalid.output +9/−0
- tests/c-ns-properties.n=0.c=flow-out.output +13/−0
- tests/c-ns-properties.output +0/−13
- tests/s-l+flow-in-block.n=2.input +3/−1
- tests/s-l+flow-in-block.n=2.output +14/−1
- tests/s-separate-in-flow.n=4.c=flow-key.empty.input +0/−0
- tests/s-separate-in-flow.n=4.c=flow-key.empty.output +0/−0
- tests/s-separate-in-flow.n=4.c=flow-key.invalid.input +0/−1
- tests/s-separate-in-flow.n=4.c=flow-key.invalid.output +0/−1
- tests/s-separate-in-flow.n=4.c=flow-key.sp.input +0/−1
- tests/s-separate-in-flow.n=4.c=flow-key.sp.output +0/−1
- tests/s-separate-in-flow.n=4.c=flow-out.empty.input +0/−0
- tests/s-separate-in-flow.n=4.c=flow-out.empty.output +0/−0
- tests/s-separate-in-flow.n=4.c=flow-out.line.input +0/−2
- tests/s-separate-in-flow.n=4.c=flow-out.line.output +0/−2
- tests/s-separate-in-flow.n=4.c=flow-out.sp.input +0/−1
- tests/s-separate-in-flow.n=4.c=flow-out.sp.output +0/−1
- tests/s-separate.n=4.c=flow-key.empty.input +0/−0
- tests/s-separate.n=4.c=flow-key.empty.output +0/−0
- tests/s-separate.n=4.c=flow-key.invalid.input +1/−0
- tests/s-separate.n=4.c=flow-key.invalid.output +1/−0
- tests/s-separate.n=4.c=flow-key.sp.input +1/−0
- tests/s-separate.n=4.c=flow-key.sp.output +1/−0
- tests/s-separate.n=4.c=flow-out.empty.input +0/−0
- tests/s-separate.n=4.c=flow-out.empty.output +0/−0
- tests/s-separate.n=4.c=flow-out.line.input +2/−0
- tests/s-separate.n=4.c=flow-out.line.output +2/−0
- tests/s-separate.n=4.c=flow-out.sp.input +1/−0
- tests/s-separate.n=4.c=flow-out.sp.output +1/−0
- yaml2yeast-test/Main.hs +1/−1
- yaml2yeast/Main.hs +28/−19
- yeast2html +45/−43
Text/Yaml/Reference.bnf view
@@ -175,7 +175,7 @@ l_empty n s = ( s_ignored_prefix n s / s_indent_lt n ) & b_normalized --- Comments: TODO+-- Comments: c_nb_comment_text = nest BeginComment & c_comment & meta ( nb_char *)@@ -185,6 +185,18 @@ s_l_comments = ( s_b_comment / sol ) & ( l_comment *) l_comment = s_separate_in_line & ( c_nb_comment_text ?) & b_ignored_any +-- Separation:++s_separate n c = case c of+ BlockIn -> s_separate_in_line+ BlockOut -> s_separate_in_line+ FlowOut -> s_separate_lines n+ FlowIn -> s_separate_lines n+ FlowKey -> s_separate_in_line++s_separate_lines n = s_l_comments & s_ignored_prefix_flow n+ / s_separate_in_line+ -- Folding: b_l_folded_specific n s = token Break b_specific & ( l_empty n s *)@@ -240,9 +252,10 @@ -- Properties: -c_ns_properties = nest BeginProperties- & c_ns_property & ( s_separate_in_line & c_ns_property *)- & nest EndProperties+c_ns_properties n c = nest BeginProperties+ & ( ( c_ns_anchor_property & ( s_separate n c & c_ns_tag_property ?) )+ / ( c_ns_tag_property & ( s_separate n c & c_ns_anchor_property ?) ) )+ & nest EndProperties c_ns_property = c_ns_anchor_property / c_ns_tag_property -- Tag:@@ -349,16 +362,6 @@ & ns_plain_char c & ( s_ns_plain_chars c *) --- Separation: TODO--s_separate_in_flow n c = case c of- FlowOut -> s_separate_lines n- FlowIn -> s_separate_lines n- FlowKey -> s_separate_in_line--s_separate_lines n = s_l_comments & s_ignored_prefix_flow n- / s_separate_in_line- -- Flow collection: in_flow c = case c of@@ -370,15 +373,15 @@ c_flow_sequence n c = nest BeginSequence & c_sequence_start ! "node"- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( ns_s_flow_seq_entries n (in_flow c) ?) & c_sequence_end & nest EndSequence ns_s_flow_seq_entries n c = ns_flow_seq_entry n c- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( c_collect_entry- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( ns_s_flow_seq_entries n c ?) ?) ns_flow_seq_entry n c = "pair" ^ ( ns_flow_map_single_pair n c / "node" ^ ns_flow_node n c )@@ -387,15 +390,15 @@ c_flow_mapping n c = nest BeginMapping & c_mapping_start ! "node"- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( ns_s_flow_map_entries n (in_flow c) ?) & c_mapping_end & nest EndMapping ns_s_flow_map_entries n c = ns_flow_map_entry n c- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( c_collect_entry- & ( s_separate_in_flow n c ?)+ & ( s_separate n c ?) & ( ns_s_flow_map_entries n c ?) ?) ns_flow_map_entry n c = nest BeginPair@@ -409,21 +412,21 @@ / s_ns_flow_map_explicit_yaml n c / s_ns_flow_map_explicit_empty n c / e_node & e_node )-s_ns_flow_map_explicit_json n c = s_separate_in_flow n c+s_ns_flow_map_explicit_json n c = s_separate n c & ( "node" ^ c_flow_json_node n c ) ! "entry"- & ( ( s_separate_in_flow n c ?) & c_ns_flow_map_adjacent_value n c+ & ( ( s_separate n c ?) & c_ns_flow_map_adjacent_value n c / e_node )-s_ns_flow_map_explicit_yaml n c = s_separate_in_flow n c+s_ns_flow_map_explicit_yaml n c = s_separate n c & ( "node" ^ ns_flow_yaml_node n c ) ! "entry"- & ( ( s_separate_in_flow n c ?) & c_ns_flow_map_separate_value n c+ & ( ( s_separate n c ?) & c_ns_flow_map_separate_value n c / e_node )-s_ns_flow_map_explicit_empty n c = s_separate_in_flow n c & e_node & c_ns_flow_map_separate_value n c+s_ns_flow_map_explicit_empty n c = s_separate n c & e_node & c_ns_flow_map_separate_value n c c_ns_flow_map_separate_value n c = c_mapping_value ! "pair"- & ( s_separate_in_flow n c & ns_flow_node n c+ & ( s_separate n c & ns_flow_node n c / e_node ) c_ns_flow_map_adjacent_value n c = c_mapping_value ! "pair"- & ( ( s_separate_in_flow n c ?) & ns_flow_node n c+ & ( ( s_separate n c ?) & ns_flow_node n c / e_node ) ns_flow_map_implicit_entry n c = c_ns_flow_map_implicit_json n c@@ -471,20 +474,20 @@ ns_flow_yaml_content n c = ns_plain n c c_flow_json_node n c = nest BeginNode- & ( c_ns_properties & s_separate_in_line ?)+ & ( c_ns_properties n c & s_separate n c ?) & c_flow_json_content n c & nest EndNode ns_flow_yaml_node n c = nest BeginNode & ( c_ns_alias- / ( c_ns_properties- & ( s_separate_in_line & ns_flow_yaml_content n c+ / ( c_ns_properties n c+ & ( s_separate n c & ns_flow_yaml_content n c / e_scalar ) ) / ns_flow_yaml_content n c ) & nest EndNode ns_flow_node n c = nest BeginNode & ( c_ns_alias- / ( c_ns_properties- & ( s_separate_in_line & ns_flow_content n c+ / ( c_ns_properties n c+ & ( s_separate n c & ns_flow_content n c / e_scalar ) ) / ns_flow_content n c ) & nest EndNode@@ -647,13 +650,13 @@ s_l__block_node n c = s_l__block_in_block n c / s_l__flow_in_block n-s_l__flow_in_block n = s_separate_in_line & ns_flow_node (n .+ 1) FlowOut & s_l_comments+s_l__flow_in_block n = s_separate n FlowOut & ns_flow_node (n .+ 1) FlowOut & s_l_comments s_l__block_in_block n c = nest BeginNode- & ( s_separate_in_line & c_ns_properties ?)+ & ( s_separate n c & c_ns_properties n c ?) & s_l__block_content n c & nest EndNode-s_l__block_content n c = s_separate_in_line & c_l__literal n- / s_separate_in_line & c_l__folded n+s_l__block_content n c = s_separate n c & c_l__literal n+ / s_separate n c & c_l__folded n / s_l_comments & l__block_sequence (seq_spaces n c) / s_l_comments & l__block_mapping n
Text/Yaml/Reference.hs view
@@ -318,6 +318,7 @@ | BeginStream -- ^ Begins YAML stream. | EndStream -- ^ Ends YAML stream. | Error -- ^ Parsing error at this point.+ | Unparsed -- ^ The rest of the input at the error point. -- For testing:. | Test -- ^ Test characters otherwise unassigned. | Detected -- ^ Detected parameter.@@ -370,6 +371,7 @@ BeginStream -> "Y" EndStream -> "y" Error -> "!"+ Unparsed -> "-" Test -> "?" Detected -> "$" @@ -1050,19 +1052,19 @@ -- implementation details from our callers. -- | 'Tokenizer' converts a (named) input text into a list of 'Token'. Errors--- are reported as tokens with the @Error@ 'Code'.-type Tokenizer = String -> C.ByteString -> [Token]+-- are reported as tokens with the @Error@ 'Code', and the unparsed text+-- following an error may be attached as a final token.+type Tokenizer = String -> C.ByteString -> Bool -> [Token] -- | @patternTokenizer pattern@ converts the /pattern/ to a simple 'Tokenizer'. patternTokenizer :: Pattern -> Tokenizer-patternTokenizer pattern name input =+patternTokenizer pattern name input withFollowing = D.toList $ patternParser (wrap pattern) (initialState name input) where patternParser (Parser parser) state = let reply = parser state tokens = commitBugs reply in case reply|>rResult of- Failed message -> D.append tokens $ D.singleton Token { tCode = Error,- tText = message }+ Failed message -> errorTokens tokens message withFollowing $ reply|>rState|>sInput Result _ -> tokens More parser' -> D.append tokens $ patternParser parser' $ reply|>rState @@ -1071,18 +1073,27 @@ -- with the @Detected@ 'Code' The result is reported as a token with the -- @Detected@ 'Code'. parserTokenizer :: (Show result, Match match result) => String -> match -> Tokenizer-parserTokenizer what parser name input =+parserTokenizer what parser name input withFollowing = D.toList $ parserParser (wrap parser) (initialState name input) where parserParser (Parser parser) state = let reply = parser state tokens = commitBugs reply in case reply|>rResult of- Failed message -> D.append tokens $ D.singleton Token { tCode = Error,- tText = message }- Result value -> D.append tokens $ D.singleton Token { tCode = Detected,- tText = what ++ "=" ++ (show value) }- More parser' -> D.append tokens $ parserParser parser' $ reply|>rState+ Failed message -> errorTokens tokens message withFollowing $ reply|>rState|>sInput+ Result value -> D.append tokens $ D.singleton Token { tCode = Detected,+ tText = what ++ "=" ++ (show value) }+ More parser' -> D.append tokens $ parserParser parser' $ reply|>rState +-- | @errorTokens tokens message withFollowing following@ appends an @Error@+-- token with the specified /message/ at the end of /tokens/, and if+-- /withFollowing/ also appends the unparsed text /following/ the error as a+-- final @Unparsed@ token.+errorTokens tokens message withFollowing following =+ let tokens' = D.append tokens $ D.singleton Token { tCode = Error, tText = message }+ in if withFollowing && following /= ""+ then D.append tokens' $ D.singleton Token { tCode = Unparsed, tText = following }+ else tokens'+ -- | @commitBugs reply@ inserts an error token if a commit was made outside a -- named choice. This should never happen outside tests. commitBugs :: Reply result -> D.DList Token@@ -1162,7 +1173,6 @@ $ PAT(c_ns_alias) $ PAT(c_ns_anchor_property) $ PAT(c_ns_local_tag_prefix)- $ PAT(c_ns_properties) $ PAT(c_ns_property) $ PAT(c_ns_shorthand_tag) $ PAT(c_ns_tag_property)@@ -1383,6 +1393,7 @@ $ PAT(c_ns_flow_map_implicit_json) $ PAT(c_ns_flow_map_separate_value) $ PAT(c_ns_flow_map_single_json)+ $ PAT(c_ns_properties) $ PAT(c_single_quoted) $ PAT(nb_double_text) $ PAT(nb_single_text)@@ -1411,7 +1422,7 @@ $ PAT(s_ns_flow_map_explicit_json) $ PAT(s_ns_flow_map_explicit_yaml) $ PAT(s_ns_plain_next)- $ PAT(s_separate_in_flow)+ $ PAT(s_separate) $ Map.empty where pat name pattern = Map.insert (pName name) (\ n c -> patternTokenizer (match $ pattern n c))
YamlReference.cabal view
@@ -1,5 +1,5 @@ Name: YamlReference-Version: 0.3+Version: 0.4 License: LGPL License-File: lgpl.txt Copyright: Oren Ben-Kiki 2007@@ -7,7 +7,7 @@ Maintainer: yaml-oren@ben-kiki.org Stability: alpha Homepage: www.ben-kiki.org/oren/YamlReference-Package-Url: www.ben-kiki.org/oren/YamlReference/YamlReference-0.3.tar.gz+Package-Url: www.ben-kiki.org/oren/YamlReference/YamlReference-0.4.tar.gz Category: Text Synopsis: YAML reference implementation Description: This package contains \"the\" reference YAML syntax parser@@ -298,10 +298,16 @@ tests/c-ns-local-tag-prefix.input tests/c-ns-local-tag-prefix.invalid.input tests/c-ns-local-tag-prefix.invalid.output- tests/c-ns-local-tag-prefix.output tests/c-ns-properties.input- tests/c-ns-properties.invalid.input- tests/c-ns-properties.invalid.output- tests/c-ns-properties.output tests/c-ns-property.anchor.input+ tests/c-ns-local-tag-prefix.output+ tests/c-ns-properties.n=0.c=block-out.input+ tests/c-ns-properties.n=0.c=block-out.invalid.input+ tests/c-ns-properties.n=0.c=block-out.invalid.output+ tests/c-ns-properties.n=0.c=block-out.output+ tests/c-ns-properties.n=0.c=flow-out.input+ tests/c-ns-properties.n=0.c=flow-out.invalid.input+ tests/c-ns-properties.n=0.c=flow-out.invalid.output+ tests/c-ns-properties.n=0.c=flow-out.output+ tests/c-ns-property.anchor.input tests/c-ns-property.anchor.output tests/c-ns-property.invalid.input tests/c-ns-property.invalid.output@@ -1118,18 +1124,6 @@ tests/s-ns-single-next.n=4.invalid.input tests/s-ns-single-next.n=4.invalid.output tests/s-ns-single-next.n=4.output- tests/s-separate-in-flow.n=4.c=flow-key.empty.input- tests/s-separate-in-flow.n=4.c=flow-key.empty.output- tests/s-separate-in-flow.n=4.c=flow-key.invalid.input- tests/s-separate-in-flow.n=4.c=flow-key.invalid.output- tests/s-separate-in-flow.n=4.c=flow-key.sp.input- tests/s-separate-in-flow.n=4.c=flow-key.sp.output- tests/s-separate-in-flow.n=4.c=flow-out.empty.input- tests/s-separate-in-flow.n=4.c=flow-out.empty.output- tests/s-separate-in-flow.n=4.c=flow-out.line.input- tests/s-separate-in-flow.n=4.c=flow-out.line.output- tests/s-separate-in-flow.n=4.c=flow-out.sp.input- tests/s-separate-in-flow.n=4.c=flow-out.sp.output tests/s-separate-in-line.invalid.input tests/s-separate-in-line.invalid.output tests/s-separate-in-line.sol.input@@ -1144,6 +1138,18 @@ tests/s-separate-lines.n=4.sol.output tests/s-separate-lines.n=4.sp.input tests/s-separate-lines.n=4.sp.output+ tests/s-separate.n=4.c=flow-key.empty.input+ tests/s-separate.n=4.c=flow-key.empty.output+ tests/s-separate.n=4.c=flow-key.invalid.input+ tests/s-separate.n=4.c=flow-key.invalid.output+ tests/s-separate.n=4.c=flow-key.sp.input+ tests/s-separate.n=4.c=flow-key.sp.output+ tests/s-separate.n=4.c=flow-out.empty.input+ tests/s-separate.n=4.c=flow-out.empty.output+ tests/s-separate.n=4.c=flow-out.line.input+ tests/s-separate.n=4.c=flow-out.line.output+ tests/s-separate.n=4.c=flow-out.sp.input+ tests/s-separate.n=4.c=flow-out.sp.output tests/s-single-multi.n=4.input tests/s-single-multi.n=4.invalid.input tests/s-single-multi.n=4.invalid.output
− tests/c-ns-properties.input
@@ -1,1 +0,0 @@-&&*!name !suffix
− tests/c-ns-properties.invalid.input
@@ -1,1 +0,0 @@-@a
− tests/c-ns-properties.invalid.output
@@ -1,3 +0,0 @@-P-G-!$InputFile$: line 1: column 0: Unexpected '@'
+ tests/c-ns-properties.n=0.c=block-out.input view
@@ -0,0 +1,1 @@+&&*!name !suffix
+ tests/c-ns-properties.n=0.c=block-out.invalid.input view
@@ -0,0 +1,1 @@+@a
+ tests/c-ns-properties.n=0.c=block-out.invalid.output view
@@ -0,0 +1,3 @@+P+G+!$InputFile$: line 1: column 0: Unexpected '@'
+ tests/c-ns-properties.n=0.c=block-out.output view
@@ -0,0 +1,13 @@+P+A+I&+t&*!name+a+w +G+H+I!+h+tsuffix+g+p
+ tests/c-ns-properties.n=0.c=flow-out.input view
@@ -0,0 +1,2 @@+!a+&b
+ tests/c-ns-properties.n=0.c=flow-out.invalid.input view
@@ -0,0 +1,2 @@+!a+!b
+ tests/c-ns-properties.n=0.c=flow-out.invalid.output view
@@ -0,0 +1,9 @@+P+G+H+I!+h+ta+g+p+!$InputFile$: line 1: column 2: Expected end of input
+ tests/c-ns-properties.n=0.c=flow-out.output view
@@ -0,0 +1,13 @@+P+G+H+I!+h+ta+g+b\x0a+A+I&+tb+a+p
− tests/c-ns-properties.output
@@ -1,13 +0,0 @@-P-A-I&-t&*!name-a-w -G-H-I!-h-tsuffix-g-p
tests/s-l+flow-in-block.n=2.input view
@@ -1,1 +1,3 @@-a++ !a+ b
tests/s-l+flow-in-block.n=2.output view
@@ -1,7 +1,20 @@+b\x0a+i +w N+P+G+H+I!+h+ta+g+p+b\x0a+i S !Commit to 'node' was made outside it-Ta+Tb s n b\x0a
− tests/s-separate-in-flow.n=4.c=flow-key.empty.input
− tests/s-separate-in-flow.n=4.c=flow-key.empty.output
− tests/s-separate-in-flow.n=4.c=flow-key.invalid.input
@@ -1,1 +0,0 @@-
− tests/s-separate-in-flow.n=4.c=flow-key.invalid.output
@@ -1,1 +0,0 @@-!$InputFile$: line 1: column 0: Expected end of input
− tests/s-separate-in-flow.n=4.c=flow-key.sp.input
@@ -1,1 +0,0 @@-
− tests/s-separate-in-flow.n=4.c=flow-key.sp.output
@@ -1,1 +0,0 @@-w
− tests/s-separate-in-flow.n=4.c=flow-out.empty.input
− tests/s-separate-in-flow.n=4.c=flow-out.empty.output
− tests/s-separate-in-flow.n=4.c=flow-out.line.input
@@ -1,2 +0,0 @@--
− tests/s-separate-in-flow.n=4.c=flow-out.line.output
@@ -1,2 +0,0 @@-b\x0a-i
− tests/s-separate-in-flow.n=4.c=flow-out.sp.input
@@ -1,1 +0,0 @@-
− tests/s-separate-in-flow.n=4.c=flow-out.sp.output
@@ -1,1 +0,0 @@-w
+ tests/s-separate.n=4.c=flow-key.empty.input view
+ tests/s-separate.n=4.c=flow-key.empty.output view
+ tests/s-separate.n=4.c=flow-key.invalid.input view
@@ -0,0 +1,1 @@+
+ tests/s-separate.n=4.c=flow-key.invalid.output view
@@ -0,0 +1,1 @@+!$InputFile$: line 1: column 0: Expected end of input
+ tests/s-separate.n=4.c=flow-key.sp.input view
@@ -0,0 +1,1 @@+
+ tests/s-separate.n=4.c=flow-key.sp.output view
@@ -0,0 +1,1 @@+w
+ tests/s-separate.n=4.c=flow-out.empty.input view
+ tests/s-separate.n=4.c=flow-out.empty.output view
+ tests/s-separate.n=4.c=flow-out.line.input view
@@ -0,0 +1,2 @@++
+ tests/s-separate.n=4.c=flow-out.line.output view
@@ -0,0 +1,2 @@+b\x0a+i
+ tests/s-separate.n=4.c=flow-out.sp.input view
@@ -0,0 +1,1 @@+
+ tests/s-separate.n=4.c=flow-out.sp.output view
@@ -0,0 +1,1 @@+w
yaml2yeast-test/Main.hs view
@@ -184,7 +184,7 @@ WithNT -> tokenizerWithNT (testProduction inputFile) (testParameter "n" inputFile) (testParameter "t" inputFile) case result of Nothing -> assertFailure $ inputFile ++ ": unknown production" ++ (show runType) ++ ": " ++ (testProduction inputFile)- Just resolved -> do let actual = embedVariables $ showTokens $ resolved inputFile input+ Just resolved -> do let actual = embedVariables $ showTokens $ resolved inputFile input False when (actual /= expected) $ writeFile (testErrorFile inputFile) actual assertEqual inputFile expected actual
yaml2yeast/Main.hs view
@@ -134,6 +134,8 @@ -- -- [@!@] Parsing error at this point. --+-- [@-@] Unparsed text following error point.+-- -- In addition, the following codes are used for testing partial productions -- and do not appear when parsing a complete YAML stream: --@@ -158,6 +160,7 @@ | Output String -- ^ Specify output file name. | Production String -- ^ Specify start production name. | Unbuffered -- ^ Disable @stdout@ bufferting.+ | Following -- ^ Emit unparsed text following an error. | ParamN (Maybe Int) -- ^ Specify $n$ parameter. | ParamT (Maybe Chomp) -- ^ Specify $t$ parameter. | ParamS (Maybe Style) -- ^ Specify $s$ parameter.@@ -177,6 +180,9 @@ Option ['u'] ["unbuffered"] (NoArg Unbuffered) "disable stdout buffering",+ Option ['f'] ["following"]+ (NoArg Following)+ "emit unparsed input following an error", Option ['p'] ["production"] (ReqArg Production "production") "top production",@@ -215,28 +221,30 @@ -- | Options controlling program behavior data Options = Options {- oToHelp :: Bool, -- ^ Whether to just print the usage.- oToUnbuffer :: Bool, -- ^ Whether to disable @stdout@ buffering.- oInput :: String, -- ^ Name of input file ("-": @stdin@).- oOutput :: String, -- ^ Name of output file ("-": @stdout@).- oProduction :: String, -- ^ Name of start production.- oN :: Maybe Int, -- ^ N parameter, if any.- oC :: Maybe Context, -- ^ C parameter, if any.- oS :: Maybe Style, -- ^ S parameter, if any.- oT :: Maybe Chomp -- ^ T parameter, if any.+ oToHelp :: Bool, -- ^ Whether to just print the usage.+ oToUnbuffer :: Bool, -- ^ Whether to disable @stdout@ buffering.+ oWithFollowing :: Bool, -- ^ Whether to emit unparsed text following an error.+ oInput :: String, -- ^ Name of input file ("-": @stdin@).+ oOutput :: String, -- ^ Name of output file ("-": @stdout@).+ oProduction :: String, -- ^ Name of start production.+ oN :: Maybe Int, -- ^ N parameter, if any.+ oC :: Maybe Context, -- ^ C parameter, if any.+ oS :: Maybe Style, -- ^ S parameter, if any.+ oT :: Maybe Chomp -- ^ T parameter, if any. } -- | Default options if no flags are specified. defaultOptions = Options {- oToHelp = False,- oToUnbuffer = False,- oInput = "-",- oOutput = "-",- oProduction = "l-yaml-stream",- oN = Nothing,- oC = Nothing,- oS = Nothing,- oT = Nothing+ oToHelp = False,+ oToUnbuffer = False,+ oWithFollowing = False,+ oInput = "-",+ oOutput = "-",+ oProduction = "l-yaml-stream",+ oN = Nothing,+ oC = Nothing,+ oS = Nothing,+ oT = Nothing } -- | @applyFlags flags options@ applies the specified /flags/ to the /options/.@@ -246,6 +254,7 @@ case flag of Help -> applyFlags flags options { oToHelp = True } Unbuffered -> applyFlags flags options { oToUnbuffer = True }+ Following -> applyFlags flags options { oWithFollowing = True } Output name -> applyFlags flags options { oOutput = name } Input name -> applyFlags flags options { oInput = name } ParamN value -> applyFlags flags options { oN = value }@@ -286,7 +295,7 @@ case resolved of Nothing -> error $ "No production " ++ (oProduction options) ++ " or it doesn't take this combination of parameters" Just parser -> do text <- fromFile (oInput options)- let tokens = parser (oInput options) text+ let tokens = parser (oInput options) text (oWithFollowing options) intoFile (oOutput options) (showTokens tokens) -- | @main@ converts an input YAML file to YEAST tokens.
yeast2html view
@@ -9,48 +9,50 @@ # YEAST byte codes. my $code2class = {- U => { code => 'U', type => 'bom', title => "Byte order mark" },- T => { code => 'T', type => 'text', title => "Content text" },- t => { code => 't', type => 'text', title => "Non-content text" },- B => { code => 'B', type => 'line', title => "Content line break" },- b => { code => 'b', type => 'line', title => "Non-content line break" },- L => { code => 'L', type => 'line', title => "Line break normalized to line feed" },- l => { code => 'l', type => 'line', title => "Line break folded to space" },- I => { code => 'I', type => 'text', title => "Indicator character" },- w => { code => 'w', type => 'text', title => "Non-content white space" },- i => { code => 'i', type => 'text', title => "Indentation white space" },- K => { code => 'K', type => 'text', title => "Document start marker" },- k => { code => 'k', type => 'text', title => "Document end marker" },- E => { code => 'E', type => 'begin', title => "Escape sequence" },- e => { code => 'e', type => 'end', title => "Escape sequence" },- C => { code => 'C', type => 'begin', title => "Comment" },- c => { code => 'c', type => 'end', title => "Comment" },- D => { code => 'D', type => 'begin', title => "Directive" },- d => { code => 'd', type => 'end', title => "Directive" },- G => { code => 'G', type => 'begin', title => "Tag" },- g => { code => 'g', type => 'end', title => "Tag" },- H => { code => 'H', type => 'begin', title => "Handle" },- h => { code => 'h', type => 'end', title => "Handle" },- A => { code => 'A', type => 'begin', title => "Anchor" },- a => { code => 'a', type => 'end', title => "Anchor" },- P => { code => 'P', type => 'begin', title => "Properties" },- p => { code => 'p', type => 'end', title => "Properties" },- R => { code => 'R', type => 'begin', title => "Alias" },- r => { code => 'r', type => 'end', title => "Alias" },- S => { code => 'S', type => 'begin', title => "Scalar" },- s => { code => 's', type => 'end', title => "Scalar" },- Q => { code => 'Q', type => 'begin', title => "Sequence" },- q => { code => 'q', type => 'end', title => "Sequence" },- M => { code => 'M', type => 'begin', title => "Mapping" },- m => { code => 'm', type => 'end', title => "Mapping" },- N => { code => 'N', type => 'begin', title => "Node" },- n => { code => 'n', type => 'end', title => "Node" },- X => { code => 'X', type => 'begin', title => "Key:value pair" },- x => { code => 'x', type => 'end', title => "Key:value pair" },- O => { code => 'O', type => 'begin', title => "Document" },- o => { code => 'o', type => 'end', title => "Document" },- Y => { code => 'Y', type => 'begin', title => "Stream" },- y => { code => 'y', type => 'end', title => "Stream" }+ U => { code => 'U', type => 'bom', title => "Byte order mark" },+ T => { code => 'T', type => 'text', title => "Content text" },+ t => { code => 't', type => 'text', title => "Non-content text" },+ B => { code => 'B', type => 'line', title => "Content line break" },+ b => { code => 'b', type => 'line', title => "Non-content line break" },+ L => { code => 'L', type => 'line', title => "Line break normalized to line feed" },+ l => { code => 'l', type => 'line', title => "Line break folded to space" },+ I => { code => 'I', type => 'text', title => "Indicator character" },+ w => { code => 'w', type => 'text', title => "Non-content white space" },+ i => { code => 'i', type => 'text', title => "Indentation white space" },+ K => { code => 'K', type => 'text', title => "Document start marker" },+ k => { code => 'k', type => 'text', title => "Document end marker" },+ E => { code => 'E', type => 'begin', title => "Escape sequence" },+ e => { code => 'e', type => 'end', title => "Escape sequence" },+ C => { code => 'C', type => 'begin', title => "Comment" },+ c => { code => 'c', type => 'end', title => "Comment" },+ D => { code => 'D', type => 'begin', title => "Directive" },+ d => { code => 'd', type => 'end', title => "Directive" },+ G => { code => 'G', type => 'begin', title => "Tag" },+ g => { code => 'g', type => 'end', title => "Tag" },+ H => { code => 'H', type => 'begin', title => "Handle" },+ h => { code => 'h', type => 'end', title => "Handle" },+ A => { code => 'A', type => 'begin', title => "Anchor" },+ a => { code => 'a', type => 'end', title => "Anchor" },+ P => { code => 'P', type => 'begin', title => "Properties" },+ p => { code => 'p', type => 'end', title => "Properties" },+ R => { code => 'R', type => 'begin', title => "Alias" },+ r => { code => 'r', type => 'end', title => "Alias" },+ S => { code => 'S', type => 'begin', title => "Scalar" },+ s => { code => 's', type => 'end', title => "Scalar" },+ Q => { code => 'Q', type => 'begin', title => "Sequence" },+ q => { code => 'q', type => 'end', title => "Sequence" },+ M => { code => 'M', type => 'begin', title => "Mapping" },+ m => { code => 'm', type => 'end', title => "Mapping" },+ N => { code => 'N', type => 'begin', title => "Node" },+ n => { code => 'n', type => 'end', title => "Node" },+ X => { code => 'X', type => 'begin', title => "Key:value pair" },+ x => { code => 'x', type => 'end', title => "Key:value pair" },+ O => { code => 'O', type => 'begin', title => "Document" },+ o => { code => 'o', type => 'end', title => "Document" },+ Y => { code => 'Y', type => 'begin', title => "Stream" },+ y => { code => 'y', type => 'end', title => "Stream" },+ '!' => { code => '!', type => 'error', title => "Error" },+ '-' => { code => '-', type => 'text', title => "Unparsed" } }; # Command line arguments.@@ -133,7 +135,7 @@ } push(@$data, [$class, $text]); }- die("Unterminated groups\n") if @$stack;+ #die("Unterminated groups\n") if @$stack; } sub print_output {