()
| 11 | } |
| 12 | |
| 13 | function* IPAddress() { |
| 14 | const first = yield Digit; |
| 15 | yield '.'; |
| 16 | const second = yield Digit; |
| 17 | yield '.'; |
| 18 | const third = yield Digit; |
| 19 | yield '.'; |
| 20 | const fourth = yield Digit; |
| 21 | yield mustEnd; |
| 22 | return [first, second, third, fourth]; |
| 23 | } |
| 24 | |
| 25 | console.log(parse('1.2.3.4', IPAddress())); |
| 26 | console.log(parse('1.2.3.256', IPAddress())); |