Overview
Comment: | s_expressions-printers-pretty-config: add a procedure to serialize pretty printer configuration |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ab7de61c8119d1e6803098ef6dda7a8e |
User & Date: | nat on 2014-03-20 21:14:11 |
Other Links: | manifest | tags |
Context
2014-03-21
| ||
20:15 | s_expressions-printers-pretty-config-tests: add a test for the serializer check-in: 3604ae2791 user: nat tags: trunk | |
2014-03-20
| ||
21:14 | s_expressions-printers-pretty-config: add a procedure to serialize pretty printer configuration check-in: ab7de61c81 user: nat tags: trunk | |
2014-03-19
| ||
20:06 | s_expressions-printers-pretty-config-tests: new test suite for pretty printer parameter deserialization check-in: 42cb88536e user: nat tags: trunk | |
Changes
Modified src/natools-s_expressions-printers-pretty-config.adb from [2cb8d50f0e] to [25b0bd7c3c].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | + | Has_Value : out Boolean); -- Decode a screen offset from a S-expression procedure Update_Casing (Casing : in out Encodings.Hex_Casing; Name : in Atom); function To_Atom (Value : in Screen_Offset) return Atom; function To_Atom (Before, After : in Entity) return Atom; function To_String (Value : in Entity) return String; ------------------------------ |
︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | end loop; Has_Value := True; Value := Result; end; end Read_Screen_Offset; function To_Atom (Value : in Screen_Offset) return Atom is Length : Count; begin Compute_Length : declare Left : Screen_Offset := Value; begin Length := 1; while Left >= 10 loop Length := Length + 1; Left := Left / 10; end loop; end Compute_Length; return Result : Atom (0 .. Length - 1) do declare I : Offset := Result'Last; Left : Screen_Offset := Value; begin loop Result (I) := Encodings.Digit_0 + Octet (Left mod 10); I := I - 1; Left := Left / 10; exit when Left = 0; end loop; pragma Assert (I + 1 = Result'First); end; end return; end To_Atom; function To_Atom (Before, After : in Entity) return Atom is begin return To_Atom (To_String (Before) & "-" & To_String (After)); end To_Atom; |
︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | end Update_Casing; --------------------------------- -- Public High Level Interface -- --------------------------------- procedure Print (Output : in out Printers.Printer'Class; Param : in Parameters) is begin -- Newline_At and Newline Output.Open_List; Output.Append_Atom (To_Atom ("newline")); case Param.Newline is when CR => Output.Append_Atom (To_Atom ("cr")); when LF => Output.Append_Atom (To_Atom ("lf")); when CR_LF => Output.Append_Atom (To_Atom ("cr-lf")); when LF_CR => Output.Append_Atom (To_Atom ("lf-cr")); end case; if Param.Newline_At = Entity_Separator'(others => (others => True)) then Output.Append_Atom (To_Atom ("all")); else Output.Append_Atom (To_Atom ("none")); for Before in Entity loop for After in Entity loop if Param.Newline_At (Before, After) then Output.Append_Atom (To_Atom (Before, After)); end if; end loop; end loop; end if; Output.Close_List; -- Space_At Output.Open_List; Output.Append_Atom (To_Atom ("space")); if Param.Space_At = Entity_Separator'(others => (others => True)) then Output.Append_Atom (To_Atom ("all")); else Output.Append_Atom (To_Atom ("none")); for Before in Entity loop for After in Entity loop if Param.Space_At (Before, After) then Output.Append_Atom (To_Atom (Before, After)); end if; end loop; end loop; end if; Output.Close_List; -- Tab_Stop Output.Open_List; Output.Append_Atom (To_Atom ("tab-stop")); Output.Append_Atom (To_Atom (Param.Tab_Stop)); Output.Close_List; -- Width if Param.Width > 0 then Output.Open_List; Output.Append_Atom (To_Atom ("width")); Output.Append_Atom (To_Atom (Param.Width)); Output.Close_List; else Output.Append_Atom (To_Atom ("no-width")); end if; -- Indentation and Indent if Param.Indentation = 0 then Output.Append_Atom (To_Atom ("no-indentation")); else Output.Open_List; Output.Append_Atom (To_Atom ("indentation")); Output.Append_Atom (To_Atom (Param.Indentation)); if Param.Indentation > 1 then case Param.Indent is when Spaces => Output.Append_Atom (To_Atom ("spaces")); when Tabs => Output.Append_Atom (To_Atom ("tabs")); when Tabs_And_Spaces => Output.Append_Atom (To_Atom ("tabbed-spaces")); end case; else case Param.Indent is when Spaces => Output.Append_Atom (To_Atom ("space")); when Tabs => Output.Append_Atom (To_Atom ("tab")); when Tabs_And_Spaces => Output.Append_Atom (To_Atom ("tabbed-space")); end case; end if; Output.Close_List; end if; -- Quoted case Param.Quoted is when No_Quoted => Output.Append_Atom (To_Atom ("no-quoted-string")); when Single_Line => Output.Append_Atom (To_Atom ("single-line-quoted-string")); when When_Shorter => Output.Append_Atom (To_Atom ("quoted-string-when-shorter")); end case; -- Quoted_Escape Output.Open_List; Output.Append_Atom (To_Atom ("escape")); case Param.Quoted_Escape is when Octal_Escape => Output.Append_Atom (To_Atom ("octal")); when Hex_Escape => Output.Append_Atom (To_Atom ("hexadecimal")); end case; Output.Close_List; -- Token Output.Open_List; Output.Append_Atom (To_Atom ("token")); case Param.Token is when No_Token => Output.Append_Atom (To_Atom ("never")); when Extended_Token => Output.Append_Atom (To_Atom ("extended")); when Standard_Token => Output.Append_Atom (To_Atom ("standard")); end case; Output.Close_List; -- Char_Encoding case Param.Char_Encoding is when UTF_8 => Output.Append_Atom (To_Atom ("utf-8")); when ASCII => Output.Append_Atom (To_Atom ("ascii")); when Latin => Output.Append_Atom (To_Atom ("latin-1")); end case; -- Hex_Casing case Param.Hex_Casing is when Encodings.Upper => Output.Append_Atom (To_Atom ("upper-case")); when Encodings.Lower => Output.Append_Atom (To_Atom ("lower-case")); end case; -- Fallback case Param.Fallback is when Base64 => Output.Append_Atom (To_Atom ("base-64")); when Hexadecimal => Output.Append_Atom (To_Atom ("hexadecimal")); when Verbatim => Output.Append_Atom (To_Atom ("verbatim")); end case; end Print; procedure Update (Param : in out Parameters; Expression : in out Lockable.Descriptor'Class) is Interpreter : Interpreters.Interpreter := Config_Interpreter; begin |
︙ |
Modified src/natools-s_expressions-printers-pretty-config.ads from [4d6729db38] to [497cc9a6a7].
︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | + + + + + | procedure Update (Interpreter : in out Interpreters.Interpreter; Param : in out Parameters; Expression : in out Lockable.Descriptor'Class); -- Update parameters using Interpreter (wrapper around its Execute) procedure Print (Output : in out Printers.Printer'Class; Param : in Parameters); -- Output parameters to S-expression printer --------------------- -- Building Blocks -- --------------------- procedure Add_Char_Encoding_Commands (Interpreter : in out Interpreters.Interpreter); |
︙ |