Skip to content

Commit 16600b8

Browse files
committed
Add hexadecimal alpha and HSL/HSLA support to text parser.
Move text parser test inputs into code.
1 parent 1e3cec1 commit 16600b8

17 files changed

+552
-368
lines changed

source/parser/TextFile.cpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2016, Albertas Vyšniauskas
2+
* Copyright (c) 2009-2022, Albertas Vyšniauskas
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -17,26 +17,26 @@
1717
*/
1818

1919
#include "TextFile.h"
20-
2120
namespace text_file_parser {
22-
Configuration::Configuration()
23-
{
24-
single_line_c_comments = true;
25-
single_line_hash_comments = true;
26-
multi_line_c_comments = true;
27-
short_hex = true;
28-
full_hex = true;
29-
css_rgb = true;
30-
css_rgba = true;
31-
float_values = true;
32-
int_values = true;
33-
}
34-
bool scanner(TextFile &text_file, const Configuration &configuration);
35-
bool TextFile::parse(const Configuration &configuration)
36-
{
37-
return scanner(*this, configuration);
38-
}
39-
TextFile::~TextFile()
40-
{
41-
}
21+
Configuration::Configuration(bool initialValue) {
22+
singleLineCComments = initialValue;
23+
singleLineHashComments = initialValue;
24+
multiLineCComments = initialValue;
25+
shortHex = initialValue;
26+
fullHex = initialValue;
27+
shortHexWithAlpha = initialValue;
28+
fullHexWithAlpha = initialValue;
29+
cssRgb = initialValue;
30+
cssRgba = initialValue;
31+
cssHsl = initialValue;
32+
cssHsla = initialValue;
33+
floatValues = initialValue;
34+
intValues = initialValue;
35+
}
36+
bool scanner(TextFile &text_file, const Configuration &configuration);
37+
bool TextFile::parse(const Configuration &configuration) {
38+
return scanner(*this, configuration);
39+
}
40+
TextFile::~TextFile() {
41+
}
4242
}

source/parser/TextFile.h

+26-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2016, Albertas Vyšniauskas
2+
* Copyright (c) 2009-2022, Albertas Vyšniauskas
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -20,29 +20,30 @@
2020
#define GPICK_PARSER_TEXT_FILE_H_
2121
#include <cstddef>
2222
struct Color;
23-
namespace text_file_parser
24-
{
25-
struct Configuration
26-
{
27-
Configuration();
28-
bool single_line_c_comments;
29-
bool single_line_hash_comments;
30-
bool multi_line_c_comments;
31-
bool short_hex;
32-
bool full_hex;
33-
bool css_rgb;
34-
bool css_rgba;
35-
bool float_values;
36-
bool int_values;
37-
};
38-
struct TextFile
39-
{
40-
bool parse(const Configuration &configuration);
41-
virtual ~TextFile();
42-
virtual void outOfMemory() = 0;
43-
virtual void syntaxError(size_t start_line, size_t start_column, size_t end_line, size_t end_colunn) = 0;
44-
virtual size_t read(char *buffer, size_t length) = 0;
45-
virtual void addColor(const Color &color) = 0;
46-
};
23+
namespace text_file_parser {
24+
struct Configuration {
25+
Configuration(bool initialValue = true);
26+
bool singleLineCComments;
27+
bool singleLineHashComments;
28+
bool multiLineCComments;
29+
bool shortHex;
30+
bool fullHex;
31+
bool shortHexWithAlpha;
32+
bool fullHexWithAlpha;
33+
bool cssRgb;
34+
bool cssRgba;
35+
bool cssHsl;
36+
bool cssHsla;
37+
bool floatValues;
38+
bool intValues;
39+
};
40+
struct TextFile {
41+
bool parse(const Configuration &configuration);
42+
virtual ~TextFile();
43+
virtual void outOfMemory() = 0;
44+
virtual void syntaxError(size_t startLine, size_t startColumn, size_t endLine, size_t endColunn) = 0;
45+
virtual size_t read(char *buffer, size_t length) = 0;
46+
virtual void addColor(const Color &color) = 0;
47+
};
4748
}
4849
#endif /* GPICK_PARSER_TEXT_FILE_H_ */

0 commit comments

Comments
 (0)