OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 | 3 |
4 library engine.scanner; | 4 library engine.scanner; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
8 import 'source.dart'; | 8 import 'source.dart'; |
9 import 'error.dart'; | 9 import 'error.dart'; |
10 import 'instrumentation.dart'; | 10 import 'instrumentation.dart'; |
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 Token get precedingComments => _precedingComment; | 1764 Token get precedingComments => _precedingComment; |
1765 } | 1765 } |
1766 /** | 1766 /** |
1767 * Instances of the abstract class {@code KeywordState} represent a state in a s
tate machine used to | 1767 * Instances of the abstract class {@code KeywordState} represent a state in a s
tate machine used to |
1768 * scan keywords. | 1768 * scan keywords. |
1769 */ | 1769 */ |
1770 class KeywordState { | 1770 class KeywordState { |
1771 /** | 1771 /** |
1772 * An empty transition table used by leaf states. | 1772 * An empty transition table used by leaf states. |
1773 */ | 1773 */ |
1774 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>.fixedLength(26
); | 1774 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); |
1775 /** | 1775 /** |
1776 * The initial state in the state machine. | 1776 * The initial state in the state machine. |
1777 */ | 1777 */ |
1778 static KeywordState KEYWORD_STATE = createKeywordStateTable(); | 1778 static KeywordState KEYWORD_STATE = createKeywordStateTable(); |
1779 /** | 1779 /** |
1780 * Create the next state in the state machine where we have already recognized
the subset of | 1780 * Create the next state in the state machine where we have already recognized
the subset of |
1781 * strings in the given array of strings starting at the given offset and havi
ng the given length. | 1781 * strings in the given array of strings starting at the given offset and havi
ng the given length. |
1782 * All of these strings have a common prefix and the next character is at the
given start index. | 1782 * All of these strings have a common prefix and the next character is at the
given start index. |
1783 * @param start the index of the character in the strings used to transition t
o a new state | 1783 * @param start the index of the character in the strings used to transition t
o a new state |
1784 * @param strings an array containing all of the strings that will be recogniz
ed by the state | 1784 * @param strings an array containing all of the strings that will be recogniz
ed by the state |
1785 * machine | 1785 * machine |
1786 * @param offset the offset of the first string in the array that has the pref
ix that is assumed | 1786 * @param offset the offset of the first string in the array that has the pref
ix that is assumed |
1787 * to have been recognized by the time we reach the state being built | 1787 * to have been recognized by the time we reach the state being built |
1788 * @param length the number of strings in the array that pass through the stat
e being built | 1788 * @param length the number of strings in the array that pass through the stat
e being built |
1789 * @return the state that was created | 1789 * @return the state that was created |
1790 */ | 1790 */ |
1791 static KeywordState computeKeywordStateTable(int start, List<String> strings,
int offset, int length12) { | 1791 static KeywordState computeKeywordStateTable(int start, List<String> strings,
int offset, int length12) { |
1792 List<KeywordState> result = new List<KeywordState>.fixedLength(26); | 1792 List<KeywordState> result = new List<KeywordState>(26); |
1793 assert(length12 != 0); | 1793 assert(length12 != 0); |
1794 int chunk = 0x0; | 1794 int chunk = 0x0; |
1795 int chunkStart = -1; | 1795 int chunkStart = -1; |
1796 bool isLeaf = false; | 1796 bool isLeaf = false; |
1797 for (int i = offset; i < offset + length12; i++) { | 1797 for (int i = offset; i < offset + length12; i++) { |
1798 if (strings[i].length == start) { | 1798 if (strings[i].length == start) { |
1799 isLeaf = true; | 1799 isLeaf = true; |
1800 } | 1800 } |
1801 if (strings[i].length > start) { | 1801 if (strings[i].length > start) { |
1802 int c = strings[i].codeUnitAt(start); | 1802 int c = strings[i].codeUnitAt(start); |
(...skipping 18 matching lines...) Expand all Loading... |
1821 } else { | 1821 } else { |
1822 return new KeywordState(result, null); | 1822 return new KeywordState(result, null); |
1823 } | 1823 } |
1824 } | 1824 } |
1825 /** | 1825 /** |
1826 * Create the initial state in the state machine. | 1826 * Create the initial state in the state machine. |
1827 * @return the state that was created | 1827 * @return the state that was created |
1828 */ | 1828 */ |
1829 static KeywordState createKeywordStateTable() { | 1829 static KeywordState createKeywordStateTable() { |
1830 List<Keyword> values2 = Keyword.values; | 1830 List<Keyword> values2 = Keyword.values; |
1831 List<String> strings = new List<String>.fixedLength(values2.length); | 1831 List<String> strings = new List<String>(values2.length); |
1832 for (int i = 0; i < values2.length; i++) { | 1832 for (int i = 0; i < values2.length; i++) { |
1833 strings[i] = values2[i].syntax; | 1833 strings[i] = values2[i].syntax; |
1834 } | 1834 } |
1835 strings.sort(); | 1835 strings.sort(); |
1836 return computeKeywordStateTable(0, strings, 0, strings.length); | 1836 return computeKeywordStateTable(0, strings, 0, strings.length); |
1837 } | 1837 } |
1838 /** | 1838 /** |
1839 * A table mapping characters to the states to which those characters will tra
nsition. (The index | 1839 * A table mapping characters to the states to which those characters will tra
nsition. (The index |
1840 * into the array is the offset from the character {@code 'a'} to the transiti
oning character.) | 1840 * into the array is the offset from the character {@code 'a'} to the transiti
oning character.) |
1841 */ | 1841 */ |
(...skipping 18 matching lines...) Expand all Loading... |
1860 * recognized a keyword. | 1860 * recognized a keyword. |
1861 * @return the keyword that was matched by reaching this state | 1861 * @return the keyword that was matched by reaching this state |
1862 */ | 1862 */ |
1863 Keyword keyword() => _keyword2; | 1863 Keyword keyword() => _keyword2; |
1864 /** | 1864 /** |
1865 * Return the state that follows this state on a transition of the given chara
cter, or{@code null} if there is no valid state reachable from this state with s
uch a transition. | 1865 * Return the state that follows this state on a transition of the given chara
cter, or{@code null} if there is no valid state reachable from this state with s
uch a transition. |
1866 * @param c the character used to transition from this state to another state | 1866 * @param c the character used to transition from this state to another state |
1867 * @return the state that follows this state on a transition of the given char
acter | 1867 * @return the state that follows this state on a transition of the given char
acter |
1868 */ | 1868 */ |
1869 KeywordState next(int c) => _table[c - 0x61]; | 1869 KeywordState next(int c) => _table[c - 0x61]; |
1870 } | 1870 } |
OLD | NEW |