-
Notifications
You must be signed in to change notification settings - Fork 172
Closed
Labels
CC++HaskellJavalistsConcerning list categories and separator/terminator/delimiter pragmasConcerning list categories and separator/terminator/delimiter pragmasprinterConcerning the generated printerConcerning the generated printer
Milestone
Description
Affects backends:
- C
- C++/NoSTL
- C++/STL
- Java
- Haskell (only for
[String]
and[Char]
, see also Haskell backend prints a list[Char]
containing characters as string #359)
For the grammar
[]. [Integer] ::= "";
(:). [Integer] ::= "-" Integer ";" [Integer];
and the input
- 1;
- 2;
- 3;
the backends C/C++/Java render the parsed syntax tree wrongly as:
1 - 2 - 3 -
Haskell does the right job (reproducing the input), and OCaml almost, with some extra space before the semicolon:
- 1 ;
- 2 ;
- 3 ;
The imperative backends seem to assume that the only terminal in the (:)
rule is the separator.
Lines 735 to 744 in e91a342
-- | Gets the separator for a list. | |
getCons :: [Rule] -> String | |
getCons rs = case find (isConsFun . funRule) rs of | |
Just (Rule _ _ cats _) -> seper cats | |
Nothing -> error $ "getCons: no construction function found in " | |
++ intercalate ", " (map (show . funRule) rs) | |
where | |
seper [] = [] | |
seper (Right x:_) = x | |
seper (Left _:xs) = seper xs |
(Found this bug by trying to understand
getCons
.)Metadata
Metadata
Assignees
Labels
CC++HaskellJavalistsConcerning list categories and separator/terminator/delimiter pragmasConcerning list categories and separator/terminator/delimiter pragmasprinterConcerning the generated printerConcerning the generated printer