@@ -1245,7 +1245,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
1245
1245
function storeMappingPair ( state , _result , overridableKeys , keyTag , keyNode , valueNode ) {
1246
1246
var index , quantity ;
1247
1247
1248
- keyNode = String ( keyNode ) ;
1248
+ keyNode = String ( keyNode [ "amf-lexical-token" ] ) ;
1249
1249
1250
1250
if ( _result === null ) {
1251
1251
_result = { } ;
@@ -1350,7 +1350,6 @@ function testDocumentSeparator(state) {
1350
1350
return true ;
1351
1351
}
1352
1352
}
1353
-
1354
1353
return false ;
1355
1354
}
1356
1355
@@ -1376,6 +1375,10 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1376
1375
_result = state . result ,
1377
1376
ch ;
1378
1377
1378
+ var startLine = state . line ;
1379
+ var startColumn = state . lineStart ;
1380
+ var startIndex = state . position ;
1381
+
1379
1382
ch = state . input . charCodeAt ( state . position ) ;
1380
1383
1381
1384
if ( is_WS_OR_EOL ( ch ) ||
@@ -1464,18 +1467,46 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1464
1467
captureSegment ( state , captureStart , captureEnd , false ) ;
1465
1468
1466
1469
if ( state . result ) {
1470
+ var endLine = state . line ;
1471
+ var endColumn = state . position - state . lineStart ;
1472
+ var endIndex = state . position ;
1473
+
1474
+ var positions = {
1475
+ "start-line" : startLine ,
1476
+ "start-column" : startColumn ,
1477
+ "start-index" : startIndex ,
1478
+ "end-line" : endLine ,
1479
+ "end-column" : endColumn ,
1480
+ "end-index" : endIndex
1481
+ } ;
1482
+ state . kind = _kind ;
1483
+ if ( state . result === 'null' ) {
1484
+ state . result = null ;
1485
+ }
1486
+ if ( state . result === 'true' ) {
1487
+ state . result = true ;
1488
+ }
1489
+ if ( state . result === 'false' ) {
1490
+ state . result = false ;
1491
+ }
1492
+ state . result = {
1493
+ "amf-lexical-token" : state . result ,
1494
+ "__location__" : positions
1495
+ } ;
1496
+
1467
1497
return true ;
1468
1498
}
1469
-
1470
- state . kind = _kind ;
1471
- state . result = _result ;
1472
1499
return false ;
1473
1500
}
1474
1501
1475
1502
function readSingleQuotedScalar ( state , nodeIndent ) {
1476
1503
var ch ,
1477
1504
captureStart , captureEnd ;
1478
1505
1506
+ var startLine = state . line ;
1507
+ var startColumn = state . lineStart ;
1508
+ var startIndex = state . position ;
1509
+
1479
1510
ch = state . input . charCodeAt ( state . position ) ;
1480
1511
1481
1512
if ( ch !== 0x27 /* ' */ ) {
@@ -1497,6 +1528,24 @@ function readSingleQuotedScalar(state, nodeIndent) {
1497
1528
state . position ++ ;
1498
1529
captureEnd = state . position ;
1499
1530
} else {
1531
+
1532
+ var endLine = state . line ;
1533
+ var endColumn = state . position - state . lineStart ;
1534
+ var endIndex = state . position ;
1535
+
1536
+ var positions = {
1537
+ "start-line" : startLine ,
1538
+ "start-column" : startColumn ,
1539
+ "start-index" : startIndex ,
1540
+ "end-line" : endLine ,
1541
+ "end-column" : endColumn ,
1542
+ "end-index" : endIndex
1543
+ } ;
1544
+
1545
+ state . result = {
1546
+ "amf-lexical-token" : state . result ,
1547
+ "__location__" : positions
1548
+ } ;
1500
1549
return true ;
1501
1550
}
1502
1551
@@ -1525,6 +1574,10 @@ function readDoubleQuotedScalar(state, nodeIndent) {
1525
1574
tmp ,
1526
1575
ch ;
1527
1576
1577
+ var startLine = state . line ;
1578
+ var startColumn = state . lineStart ;
1579
+ var startIndex = state . position ;
1580
+
1528
1581
ch = state . input . charCodeAt ( state . position ) ;
1529
1582
1530
1583
if ( ch !== 0x22 /* " */ ) {
@@ -1540,6 +1593,25 @@ function readDoubleQuotedScalar(state, nodeIndent) {
1540
1593
if ( ch === 0x22 /* " */ ) {
1541
1594
captureSegment ( state , captureStart , state . position , true ) ;
1542
1595
state . position ++ ;
1596
+
1597
+ var endLine = state . line ;
1598
+ var endColumn = state . position - state . lineStart ;
1599
+ var endIndex = state . position ;
1600
+
1601
+ var positions = {
1602
+ "start-line" : startLine ,
1603
+ "start-column" : startColumn ,
1604
+ "start-index" : startIndex ,
1605
+ "end-line" : endLine ,
1606
+ "end-column" : endColumn ,
1607
+ "end-index" : endIndex
1608
+ } ;
1609
+
1610
+ state . result = {
1611
+ "amf-lexical-token" : state . result ,
1612
+ "__location__" : positions
1613
+ } ;
1614
+
1543
1615
return true ;
1544
1616
1545
1617
} else if ( ch === 0x5C /* \ */ ) {
@@ -1713,6 +1785,10 @@ function readBlockScalar(state, nodeIndent) {
1713
1785
tmp ,
1714
1786
ch ;
1715
1787
1788
+ var startLine = state . line ;
1789
+ var startColumn = state . lineStart ;
1790
+ var startIndex = state . position ;
1791
+
1716
1792
ch = state . input . charCodeAt ( state . position ) ;
1717
1793
1718
1794
if ( ch === 0x7C /* | */ ) {
@@ -1841,6 +1917,24 @@ function readBlockScalar(state, nodeIndent) {
1841
1917
captureSegment ( state , captureStart , state . position , false ) ;
1842
1918
}
1843
1919
1920
+ var endLine = state . line ;
1921
+ var endColumn = state . position - state . lineStart ;
1922
+ var endIndex = state . position ;
1923
+
1924
+ var positions = {
1925
+ "start-line" : startLine ,
1926
+ "start-column" : startColumn ,
1927
+ "start-index" : startIndex ,
1928
+ "end-line" : endLine ,
1929
+ "end-column" : endColumn ,
1930
+ "end-index" : endIndex
1931
+ } ;
1932
+
1933
+ state . result = {
1934
+ "amf-lexical-token" : state . result ,
1935
+ "__location__" : positions
1936
+ } ;
1937
+
1844
1938
return true ;
1845
1939
}
1846
1940
@@ -2379,16 +2473,26 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
2379
2473
}
2380
2474
}
2381
2475
} else if ( _hasOwnProperty . call ( state . typeMap [ state . kind || 'fallback' ] , state . tag ) ) {
2476
+ var isLexicaltoken = false ;
2477
+ var lexicalLocation = null ;
2478
+ if ( state . result && state . result [ "amf-lexical-token" ] ) {
2479
+ lexicalLocation = state . result [ "__location__" ] ;
2480
+ state . result = state . result [ "amf-lexical-token" ] ;
2481
+ isLexicaltoken = true ;
2482
+ }
2382
2483
type = state . typeMap [ state . kind || 'fallback' ] [ state . tag ] ;
2383
2484
2384
- if ( state . result !== null && type . kind !== state . kind ) {
2485
+ if ( ! isLexicaltoken && state . result !== null && type . kind !== state . kind ) {
2385
2486
throwError ( state , 'unacceptable node kind for !<' + state . tag + '> tag; it should be "' + type . kind + '", not "' + state . kind + '"' ) ;
2386
2487
}
2387
2488
2388
2489
if ( ! type . resolve ( state . result ) ) { // `state.result` updated in resolver if matched
2389
2490
throwError ( state , 'cannot resolve a node with !<' + state . tag + '> explicit tag' ) ;
2390
2491
} else {
2391
2492
state . result = type . construct ( state . result ) ;
2493
+ if ( lexicalLocation != null ) {
2494
+ state . result [ "__location__" ] = lexicalLocation ;
2495
+ }
2392
2496
if ( state . anchor !== null ) {
2393
2497
state . anchorMap [ state . anchor ] = state . result ;
2394
2498
}
@@ -4115,7 +4219,11 @@ var collectLibraries = function (fragment, location) {
4115
4219
var libraries = fragment . uses || { } ;
4116
4220
for ( var p in libraries ) {
4117
4221
if ( p !== "__location__" ) {
4118
- var resolvedLocation = resolvePath ( location , libraries [ p ] ) ;
4222
+ var value = libraries [ p ] ;
4223
+ if ( typeof ( value ) === "object" && value [ "amf-lexical-token" ] ) {
4224
+ value = value [ "amf-lexical-token" ] ;
4225
+ }
4226
+ var resolvedLocation = resolvePath ( location , value ) ;
4119
4227
PENDING_LIBRARIES . push ( {
4120
4228
"path" : libraries [ p ] ,
4121
4229
"location" : resolvedLocation ,
@@ -4211,12 +4319,8 @@ global.JS_YAML.parseYamlFile = parseYamlFile;
4211
4319
global . JS_YAML . parseYamlString = parseYamlString ;
4212
4320
global . JS_YAML . dump = yaml . dump ;
4213
4321
global . JS_REST = function ( location ) {
4214
- console . log ( "USING PROXY?" ) ;
4215
4322
if ( typeof ( global . JS_USE_PROXY ) !== "undefined" ) {
4216
- console . log ( "YES: " + global . JS_USE_PROXY . replace ( "$URL" , encodeURIComponent ( location ) ) ) ;
4217
4323
location = global . JS_USE_PROXY . replace ( "$URL" , encodeURIComponent ( location ) ) ;
4218
- } else {
4219
- console . log ( "NOPE!" ) ;
4220
4324
}
4221
4325
return rest ( location ) ;
4222
4326
} ;
0 commit comments