04.02.2013 Views

HTML 5 Draft Standard - 30 July 2009 - Huihoo

HTML 5 Draft Standard - 30 July 2009 - Huihoo

HTML 5 Draft Standard - 30 July 2009 - Huihoo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

44<br />

The rules for parsing non-negative integers are as given in the following algorithm. When<br />

invoked, the steps must be followed in the order given, aborting at the first step that returns a<br />

value. This algorithm will either return zero, a positive integer, or an error. Leading spaces are<br />

ignored. Trailing spaces and any trailing garbage characters are ignored.<br />

1. Let input be the string being parsed.<br />

2. Let position be a pointer into input, initially pointing at the start of the string.<br />

3. Let value have the value 0.<br />

4. Skip whitespace (page 42).<br />

5. If position is past the end of input, return an error.<br />

6. If the next character is a U+002B PLUS SIGN character (+), advance position to the next<br />

character.<br />

7. If position is past the end of input, return an error.<br />

8. If the next character is not one of U+00<strong>30</strong> DIGIT ZERO (0) .. U+0039 DIGIT NINE (9),<br />

then return an error.<br />

9. Loop: If the next character is one of U+00<strong>30</strong> DIGIT ZERO (0) .. U+0039 DIGIT NINE (9):<br />

10. Return value.<br />

1. Multiply value by ten.<br />

2. Add the value of the current character (0..9) to value.<br />

3. Advance position to the next character.<br />

4. If position is not past the end of input, return to the top of the step labeled loop<br />

in the overall algorithm (that's the step within which these substeps find<br />

themselves).<br />

2.4.4.2 Signed integers<br />

A string is a valid integer if it consists of one or more characters in the range U+00<strong>30</strong> DIGIT<br />

ZERO (0) to U+0039 DIGIT NINE (9), optionally prefixed with a U+002D HYPHEN-MINUS ("-")<br />

character.<br />

A valid integer (page 44) without a U+002D HYPHEN-MINUS ("-") prefix represents the number<br />

that is represented in base ten by that string of digits. A valid integer (page 44) with a U+002D<br />

HYPHEN-MINUS ("-") prefix represents the number represented in base ten by the string of digits<br />

that follows the U+002D HYPHEN-MINUS, subtracted from zero.<br />

The rules for parsing integers are similar to the rules for non-negative integers (page 44),<br />

and are as given in the following algorithm. When invoked, the steps must be followed in the<br />

order given, aborting at the first step that returns a value. This algorithm will either return an

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!