(lval ScanSymType, ch int, errorID, fconstID, iconstID int32)
| 701 | } |
| 702 | |
| 703 | func (s *Scanner) scanNumberImpl(lval ScanSymType, ch int, errorID, fconstID, iconstID int32) { |
| 704 | start := s.pos - 1 |
| 705 | isHex := false |
| 706 | hasDecimal := ch == '.' |
| 707 | hasExponent := false |
| 708 | |
| 709 | for { |
| 710 | ch := s.peek() |
| 711 | if (isHex && lexbase.IsHexDigit(ch)) || lexbase.IsDigit(ch) { |
| 712 | s.pos++ |
| 713 | continue |
| 714 | } |
| 715 | if ch == 'x' || ch == 'X' { |
| 716 | if isHex || s.in[start] != '0' || s.pos != start+1 { |
| 717 | lval.SetID(errorID) |
| 718 | lval.SetStr(errInvalidHexNumeric) |
| 719 | return |
| 720 | } |
| 721 | s.pos++ |
| 722 | isHex = true |
| 723 | continue |
| 724 | } |
| 725 | if isHex { |
| 726 | break |
| 727 | } |
| 728 | if ch == '.' { |
| 729 | if hasDecimal || hasExponent { |
| 730 | break |
| 731 | } |
| 732 | s.pos++ |
| 733 | if s.peek() == '.' { |
| 734 | // Found ".." while scanning a number: back up to the end of the |
| 735 | // integer. |
| 736 | s.pos-- |
| 737 | break |
| 738 | } |
| 739 | hasDecimal = true |
| 740 | continue |
| 741 | } |
| 742 | if ch == 'e' || ch == 'E' { |
| 743 | if hasExponent { |
| 744 | break |
| 745 | } |
| 746 | hasExponent = true |
| 747 | s.pos++ |
| 748 | ch = s.peek() |
| 749 | if ch == '-' || ch == '+' { |
| 750 | s.pos++ |
| 751 | ch = s.peek() |
| 752 | } |
| 753 | if !lexbase.IsDigit(ch) { |
| 754 | lval.SetID(errorID) |
| 755 | lval.SetStr("invalid floating point literal") |
| 756 | return |
| 757 | } |
| 758 | continue |
| 759 | } |
| 760 | break |
no test coverage detected