aboutsummaryrefslogtreecommitdiff
path: root/src/cssparser.hh
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-15 21:15:08 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-15 21:15:08 +0100
commitf68785a65aed9ce40d9aec5fbf7f9cec3af1b384 (patch)
treee5a0fe1d6924adde42d48d4fd96689d0de4cea82 /src/cssparser.hh
parent39803b40143e5bc3e4d842def88f54e255a5290d (diff)
replace a_Css_parse(), a_Css_parse_declaration() with static methods
Diffstat (limited to 'src/cssparser.hh')
-rw-r--r--src/cssparser.hh47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/cssparser.hh b/src/cssparser.hh
index bfeca95d..4802510d 100644
--- a/src/cssparser.hh
+++ b/src/cssparser.hh
@@ -9,13 +9,48 @@ typedef struct {
const char *const *enum_symbols;
} CssPropertyInfo;
-void a_Css_parse (CssContext *context,
- const char *buf,
- int buflen,
- CssOrigin origin);
+extern const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST];
-CssPropertyList *a_Css_parse_declaration(const char *buf, int buflen);
+typedef enum {
+ CSS_TK_DECINT, CSS_TK_FLOAT, CSS_TK_COLOR, CSS_TK_SYMBOL, CSS_TK_STRING,
+ CSS_TK_CHAR, CSS_TK_END
+} CssTokenType;
-extern const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST];
+/* Applies to symbol lengths and string literals. */
+#define CSS_MAX_STR_LEN 256
+
+class CssParser {
+ private:
+ CssContext *context;
+ CssOrigin origin;
+
+ const char *buf;
+ int buflen, bufptr;
+
+ CssTokenType ttype;
+ char tval[CSS_MAX_STR_LEN];
+ bool within_block;
+ bool space_separated; /* used when parsing CSS selectors */
+
+ CssParser(CssContext *context, CssOrigin origin,
+ const char *buf, int buflen);
+ int getc();
+ void ungetc();
+ void nextToken();
+ bool tokenMatchesProperty(CssPropertyName prop, CssValueType * type);
+ bool parseValue(CssPropertyName prop, CssValueType type,
+ CssPropertyValue * val);
+ bool parseWeight();
+ void parseDeclaration(CssPropertyList * props,
+ CssPropertyList * importantProps);
+ bool parseSimpleSelector(CssSimpleSelector *selector);
+ CssSelector *parseSelector();
+ void parseRuleset();
+
+ public:
+ static CssPropertyList *parseDeclarationBlock(const char *buf, int buflen);
+ static void parse(CssContext *context, const char *buf, int buflen,
+ CssOrigin origin);
+};
#endif