* Parse DTS content
(content)
| 1024 | * Parse DTS content |
| 1025 | */ |
| 1026 | parse(content) { |
| 1027 | this.content = content; |
| 1028 | this.contentS = new String(content); // to avoid temporary instances |
| 1029 | this.pos = 0; |
| 1030 | this.length = content.length; |
| 1031 | |
| 1032 | const result = { |
| 1033 | version: null, |
| 1034 | nodes: {}, |
| 1035 | includes: [], |
| 1036 | comments: [] |
| 1037 | }; |
| 1038 | |
| 1039 | // Extract version quickly |
| 1040 | const versionIndex = content.indexOf('/dts-v1/'); |
| 1041 | if (versionIndex !== -1) { |
| 1042 | result.version = 'v1'; |
| 1043 | } |
| 1044 | |
| 1045 | // Skip to root node |
| 1046 | this.skipToRoot(); |
| 1047 | |
| 1048 | if (this.pos < this.length && this.content.charCodeAt(this.pos) === SLASH) { |
| 1049 | const nextCode = this.pos + 1 < this.length ? this.content.charCodeAt(this.pos + 1) : 0; |
| 1050 | if (nextCode !== 42) { // not '/*' |
| 1051 | const rootNode = this.parseNode(); |
| 1052 | if (rootNode) { |
| 1053 | result.nodes[rootNode.name] = rootNode; |
| 1054 | } |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | return result; |
| 1059 | } |
| 1060 | |
| 1061 | isWhitespace(code) { |
| 1062 | return CHAR_TABLE[code] & WHITESPACE; |
no test coverage detected