@@ -260,7 +260,7 @@ engine.PolarityExpression = function(ctx, parentData, node) {
260260
261261engine . TypeSpecifier = function ( ctx , parentData , node ) {
262262 let namespace , name ;
263- const identifiers = node . text . split ( '.' ) . map ( i => i . replace ( / ( ^ ` | ` $ ) / g , "" ) ) ;
263+ const identifiers = node . text . split ( '.' ) . map ( getDelimitedIdentifierVal ) ;
264264 switch ( identifiers . length ) {
265265 case 2 :
266266 [ namespace , name ] = identifiers ;
@@ -369,24 +369,10 @@ engine.StringLiteral = function(ctx, parentData, node) {
369369 * @return {string }
370370 */
371371function getStringLiteralVal ( str ) {
372- return str . replace ( / ( ^ ' | ' $ ) / g, "" )
373- . replace ( / \\ ( u \d { 4 } | .) / g, function ( match , submatch ) {
374- switch ( match ) {
375- case '\\r' :
376- return '\r' ;
377- case '\\n' :
378- return "\n" ;
379- case '\\t' :
380- return '\t' ;
381- case '\\f' :
382- return '\f' ;
383- default :
384- if ( submatch . length > 1 )
385- return String . fromCharCode ( '0x' + submatch . slice ( 1 ) ) ;
386- else
387- return submatch ;
388- }
389- } ) ;
372+ if ( str && str [ 0 ] === "'" && str [ str . length - 1 ] === "'" ) {
373+ return handleStringEscapes ( str . slice ( 1 , - 1 ) ) ;
374+ }
375+ return str ;
390376}
391377
392378engine . BooleanLiteral = function ( ctx , parentData , node ) {
@@ -450,12 +436,49 @@ engine.Identifier = function(ctx, parentData, node) {
450436} ;
451437
452438/**
453- * Removes the beginning and ending back-quotes .
439+ * Resolves an identifier value, including delimited identifiers .
454440 * @param {string } str - identifier string
455441 * @return {string }
456442 */
457443function getIdentifierVal ( str ) {
458- return str . replace ( / ( ^ ` | ` $ ) / g, "" ) ;
444+ return getDelimitedIdentifierVal ( str ) ;
445+ }
446+
447+ /**
448+ * Handles string-style escape sequences.
449+ * @param {string } str - string content without surrounding quotes
450+ * @return {string }
451+ */
452+ function handleStringEscapes ( str ) {
453+ return str . replace ( / \\ ( u \d { 4 } | .) / g, function ( match , submatch ) {
454+ switch ( match ) {
455+ case '\\r' :
456+ return '\r' ;
457+ case '\\n' :
458+ return "\n" ;
459+ case '\\t' :
460+ return '\t' ;
461+ case '\\f' :
462+ return '\f' ;
463+ default :
464+ if ( submatch . length > 1 ) {
465+ return String . fromCharCode ( '0x' + submatch . slice ( 1 ) ) ;
466+ }
467+ return submatch ;
468+ }
469+ } ) ;
470+ }
471+
472+ /**
473+ * Removes the beginning and ending back-quotes and handles escapes.
474+ * @param {string } str - identifier string
475+ * @return {string }
476+ */
477+ function getDelimitedIdentifierVal ( str ) {
478+ if ( str && str [ 0 ] === '`' && str [ str . length - 1 ] === '`' ) {
479+ return handleStringEscapes ( str . slice ( 1 , - 1 ) ) ;
480+ }
481+ return str ;
459482}
460483
461484engine . InvocationTerm = function ( ctx , parentData , node ) {
0 commit comments