Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file was generated by LibCSS gen_parser
  3.  *
  4.  * Generated from:
  5.  *
  6.  * speech_rate:CSS_PROP_SPEECH_RATE IDENT:( INHERIT: X_SLOW:0,SPEECH_RATE_X_SLOW SLOW:0,SPEECH_RATE_SLOW MEDIUM:0,SPEECH_RATE_MEDIUM FAST:0,SPEECH_RATE_FAST X_FAST:0,SPEECH_RATE_X_FAST FASTER:0,SPEECH_RATE_FASTER SLOWER:0,SPEECH_RATE_SLOWER IDENT:) NUMBER:( false:SPEECH_RATE_SET RANGE:num<0 NUMBER:)
  7.  *
  8.  * Licensed under the MIT License,
  9.  *                http://www.opensource.org/licenses/mit-license.php
  10.  * Copyright 2010 The NetSurf Browser Project.
  11.  */
  12.  
  13. #include <assert.h>
  14. #include <string.h>
  15.  
  16. #include "bytecode/bytecode.h"
  17. #include "bytecode/opcodes.h"
  18. #include "parse/properties/properties.h"
  19. #include "parse/properties/utils.h"
  20.  
  21. /**
  22.  * Parse speech_rate
  23.  *
  24.  * \param c       Parsing context
  25.  * \param vector  Vector of tokens to process
  26.  * \param ctx     Pointer to vector iteration context
  27.  * \param result  resulting style
  28.  * \return CSS_OK on success,
  29.  *         CSS_NOMEM on memory exhaustion,
  30.  *         CSS_INVALID if the input is not valid
  31.  *
  32.  * Post condition: \a *ctx is updated with the next token to process
  33.  *                 If the input is invalid, then \a *ctx remains unchanged.
  34.  */
  35. css_error css__parse_speech_rate(css_language *c,
  36.                 const parserutils_vector *vector, int *ctx,
  37.                 css_style *result)
  38. {
  39.         int orig_ctx = *ctx;
  40.         css_error error;
  41.         const css_token *token;
  42.         bool match;
  43.  
  44.         token = parserutils_vector_iterate(vector, ctx);
  45.         if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_NUMBER))) {
  46.                 *ctx = orig_ctx;
  47.                 return CSS_INVALID;
  48.         }
  49.  
  50.         if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
  51.                         error = css_stylesheet_style_inherit(result, CSS_PROP_SPEECH_RATE);
  52.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[X_SLOW], &match) == lwc_error_ok && match)) {
  53.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_X_SLOW);
  54.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[SLOW], &match) == lwc_error_ok && match)) {
  55.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_SLOW);
  56.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[MEDIUM], &match) == lwc_error_ok && match)) {
  57.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_MEDIUM);
  58.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[FAST], &match) == lwc_error_ok && match)) {
  59.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_FAST);
  60.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[X_FAST], &match) == lwc_error_ok && match)) {
  61.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_X_FAST);
  62.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[FASTER], &match) == lwc_error_ok && match)) {
  63.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_FASTER);
  64.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[SLOWER], &match) == lwc_error_ok && match)) {
  65.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0,SPEECH_RATE_SLOWER);
  66.         } else if (token->type == CSS_TOKEN_NUMBER) {
  67.                 css_fixed num = 0;
  68.                 size_t consumed = 0;
  69.  
  70.                 num = css__number_from_lwc_string(token->idata, false, &consumed);
  71.                 /* Invalid if there are trailing characters */
  72.                 if (consumed != lwc_string_length(token->idata)) {
  73.                         *ctx = orig_ctx;
  74.                         return CSS_INVALID;
  75.                 }
  76.                 if (num<0) {
  77.                         *ctx = orig_ctx;
  78.                         return CSS_INVALID;
  79.                 }
  80.  
  81.                 error = css__stylesheet_style_appendOPV(result, CSS_PROP_SPEECH_RATE, 0, SPEECH_RATE_SET);
  82.                 if (error != CSS_OK) {
  83.                         *ctx = orig_ctx;
  84.                         return error;
  85.                 }
  86.  
  87.                 error = css__stylesheet_style_append(result, num);
  88.         } else {
  89.                 error = CSS_INVALID;
  90.         }
  91.  
  92.         if (error != CSS_OK)
  93.                 *ctx = orig_ctx;
  94.        
  95.         return error;
  96. }
  97.  
  98.