mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
fix parser reserved words
This commit is contained in:
@@ -724,7 +724,10 @@ const function_call_or_member_access = nested =>
|
|||||||
),
|
),
|
||||||
// Adjust identifier to string literal
|
// Adjust identifier to string literal
|
||||||
if_ok(
|
if_ok(
|
||||||
|
either(
|
||||||
identifier,
|
identifier,
|
||||||
|
by_type('keyword'),
|
||||||
|
),
|
||||||
iden => ({...iden,
|
iden => ({...iden,
|
||||||
type: 'string_literal',
|
type: 'string_literal',
|
||||||
value: '"' + iden.value + '"',
|
value: '"' + iden.value + '"',
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
export const reserved = [
|
export const reserved = [
|
||||||
'break',
|
'break',
|
||||||
'case',
|
'case',
|
||||||
// TODO: fix parser to allow catch be an Object key, as other reserved words.
|
'catch',
|
||||||
// Currently we make exception for promise.catch
|
|
||||||
// 'catch',
|
|
||||||
'class',
|
'class',
|
||||||
'const',
|
'const',
|
||||||
'continue',
|
'continue',
|
||||||
@@ -16,9 +14,7 @@ export const reserved = [
|
|||||||
'else',
|
'else',
|
||||||
'export',
|
'export',
|
||||||
'extends',
|
'extends',
|
||||||
// TODO: fix parser to allow finally be an Object key, as other reserved words.
|
'finally',
|
||||||
// Currently we make exception for promise.finally
|
|
||||||
// 'finally',
|
|
||||||
'for',
|
'for',
|
||||||
'function',
|
'function',
|
||||||
'if',
|
'if',
|
||||||
@@ -36,9 +32,7 @@ export const reserved = [
|
|||||||
'var',
|
'var',
|
||||||
'void',
|
'void',
|
||||||
'while',
|
'while',
|
||||||
// TODO: fix parser to allow 'with' be an Object key, as other reserved words.
|
'with',
|
||||||
// Currently we make exception for Array.with
|
|
||||||
// 'with',
|
|
||||||
'yield',
|
'yield',
|
||||||
'enum',
|
'enum',
|
||||||
'implements',
|
'implements',
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ import {
|
|||||||
|
|
||||||
export const tests = [
|
export const tests = [
|
||||||
|
|
||||||
|
test('reserved words', () => {
|
||||||
|
const result = do_parse('let catch')
|
||||||
|
assert_equal(result.ok, false)
|
||||||
|
assert_equal(result.problems[0].index, 4)
|
||||||
|
}),
|
||||||
|
|
||||||
test('invalid token in the beginning', () => {
|
test('invalid token in the beginning', () => {
|
||||||
const result = do_parse('# import')
|
const result = do_parse('# import')
|
||||||
assert_equal(result, {
|
assert_equal(result, {
|
||||||
|
|||||||
Reference in New Issue
Block a user