MCPcopy Create free account
hub / github.com/LibPDF-js/core / parseKeyword

Method parseKeyword

src/parser/object-parser.ts:146–168  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

144 }
145
146 private parseKeyword(value: string): ParseResult {
147 this.shift();
148
149 switch (value) {
150 case "null":
151 return { object: PdfNull.instance, hasStream: false };
152
153 case "true":
154 return { object: PdfBool.TRUE, hasStream: false };
155
156 case "false":
157 return { object: PdfBool.FALSE, hasStream: false };
158
159 default:
160 if (this.recoveryMode) {
161 this.warn(`Unexpected keyword: ${value}, treating as null`);
162
163 return { object: PdfNull.instance, hasStream: false };
164 }
165
166 throw new ObjectParseError(`Unexpected keyword: ${value}`);
167 }
168 }
169
170 private parseNumberOrRef(firstToken: Token & { type: "number" }): ParseResult {
171 const firstNum = firstToken.value;

Callers 1

parseValueMethod · 0.95

Calls 2

shiftMethod · 0.95
warnMethod · 0.95

Tested by

no test coverage detected