Skip to content

Commit

Permalink
Parse string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
huynhtrankhanh committed Dec 5, 2023
1 parent 4bee8b6 commit 2517ae0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions compiler/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ export class CoqCPASTTransformer {
return { type: 'local binder', name: node.name, location: node.loc }
} else if (
node.type === 'Literal' &&
(typeof node.value === 'number' || typeof node.value === 'boolean')
(typeof node.value === 'number' ||
typeof node.value === 'boolean' ||
typeof node.value === 'string')
) {
if (node.raw === undefined) {
throw new ParseError(
Expand All @@ -450,8 +452,13 @@ export class CoqCPASTTransformer {
}
return {
type: 'literal',
valueType: typeof node.value === 'number' ? 'number' : 'boolean',
raw: node.raw,
valueType:
typeof node.value === 'number'
? 'number'
: typeof node.value === 'boolean'
? 'boolean'
: 'string',
raw: typeof node.value === 'string' ? node.value : node.raw,
location: node.loc,
}
} else if (node.type === 'BinaryExpression') {
Expand Down

0 comments on commit 2517ae0

Please sign in to comment.