@@ -926,6 +926,7 @@ local function parseShortString()
926926 Index = Index + 2
927927 local stringIndex = 0
928928 local currentOffset = startOffset + 1
929+ local escs = {}
929930 while true do
930931 local token = Tokens [Index + 1 ]
931932 if token == mark then
@@ -954,13 +955,18 @@ local function parseShortString()
954955 if not Tokens [Index ] then
955956 goto CONTINUE
956957 end
958+ local escLeft = getPosition (currentOffset , ' left' )
957959 -- has space?
958960 if Tokens [Index ] - currentOffset > 1 then
961+ local right = getPosition (currentOffset + 1 , ' right' )
959962 pushError {
960963 type = ' ERR_ESC' ,
961- start = getPosition ( currentOffset , ' left ' ) ,
962- finish = getPosition ( currentOffset + 1 , ' right' ) ,
964+ start = escLeft ,
965+ finish = right ,
963966 }
967+ escs [# escs + 1 ] = escLeft
968+ escs [# escs + 1 ] = right
969+ escs [# escs + 1 ] = ' err'
964970 goto CONTINUE
965971 end
966972 local nextToken = ssub (Tokens [Index + 1 ], 1 , 1 )
@@ -969,19 +975,28 @@ local function parseShortString()
969975 stringPool [stringIndex ] = EscMap [nextToken ]
970976 currentOffset = Tokens [Index ] + # nextToken
971977 Index = Index + 2
978+ escs [# escs + 1 ] = escLeft
979+ escs [# escs + 1 ] = escLeft + 2
980+ escs [# escs + 1 ] = ' normal'
972981 goto CONTINUE
973982 end
974983 if nextToken == mark then
975984 stringIndex = stringIndex + 1
976985 stringPool [stringIndex ] = mark
977986 currentOffset = Tokens [Index ] + # nextToken
978987 Index = Index + 2
988+ escs [# escs + 1 ] = escLeft
989+ escs [# escs + 1 ] = escLeft + 2
990+ escs [# escs + 1 ] = ' normal'
979991 goto CONTINUE
980992 end
981993 if nextToken == ' z' then
982994 Index = Index + 2
983995 repeat until not skipNL ()
984996 currentOffset = Tokens [Index ]
997+ escs [# escs + 1 ] = escLeft
998+ escs [# escs + 1 ] = escLeft + 2
999+ escs [# escs + 1 ] = ' normal'
9851000 goto CONTINUE
9861001 end
9871002 if CharMapNumber [nextToken ] then
@@ -991,13 +1006,21 @@ local function parseShortString()
9911006 end
9921007 currentOffset = Tokens [Index ] + # numbers
9931008 fastForwardToken (currentOffset )
1009+ local right = getPosition (currentOffset - 1 , ' right' )
9941010 local byte = tointeger (numbers )
9951011 if byte <= 255 then
9961012 stringIndex = stringIndex + 1
9971013 stringPool [stringIndex ] = schar (byte )
9981014 else
999- -- TODO pushError
1015+ pushError {
1016+ type = ' ERR_ESC' ,
1017+ start = escLeft ,
1018+ finish = right ,
1019+ }
10001020 end
1021+ escs [# escs + 1 ] = escLeft
1022+ escs [# escs + 1 ] = right
1023+ escs [# escs + 1 ] = ' byte'
10011024 goto CONTINUE
10021025 end
10031026 if nextToken == ' x' then
@@ -1016,6 +1039,10 @@ local function parseShortString()
10161039 finish = getPosition (currentOffset + 1 , ' right' ),
10171040 }
10181041 end
1042+ local right = getPosition (currentOffset + 1 , ' right' )
1043+ escs [# escs + 1 ] = escLeft
1044+ escs [# escs + 1 ] = right
1045+ escs [# escs + 1 ] = ' byte'
10191046 if State .version == ' Lua 5.1' then
10201047 pushError {
10211048 type = ' ERR_ESC' ,
@@ -1038,20 +1065,32 @@ local function parseShortString()
10381065 end
10391066 currentOffset = newOffset
10401067 fastForwardToken (currentOffset - 1 )
1068+ local right = getPosition (currentOffset + 1 , ' right' )
1069+ escs [# escs + 1 ] = escLeft
1070+ escs [# escs + 1 ] = right
1071+ escs [# escs + 1 ] = ' unicode'
10411072 goto CONTINUE
10421073 end
10431074 if NLMap [nextToken ] then
10441075 stringIndex = stringIndex + 1
10451076 stringPool [stringIndex ] = ' \n '
10461077 currentOffset = Tokens [Index ] + # nextToken
10471078 skipNL ()
1079+ local right = getPosition (currentOffset + 1 , ' right' )
1080+ escs [# escs + 1 ] = escLeft
1081+ escs [# escs + 1 ] = right
1082+ escs [# escs + 1 ] = ' normal'
10481083 goto CONTINUE
10491084 end
1085+ local right = getPosition (currentOffset + 1 , ' right' )
10501086 pushError {
10511087 type = ' ERR_ESC' ,
1052- start = getPosition ( currentOffset , ' left ' ) ,
1053- finish = getPosition ( currentOffset + 1 , ' right' ) ,
1088+ start = escLeft ,
1089+ finish = right ,
10541090 }
1091+ escs [# escs + 1 ] = escLeft
1092+ escs [# escs + 1 ] = right
1093+ escs [# escs + 1 ] = ' err'
10551094 end
10561095 Index = Index + 2
10571096 :: CONTINUE::
@@ -1061,6 +1100,7 @@ local function parseShortString()
10611100 type = ' string' ,
10621101 start = startPos ,
10631102 finish = lastRightPosition (),
1103+ escs = # escs > 0 and escs or nil ,
10641104 [1 ] = stringResult ,
10651105 [2 ] = mark ,
10661106 }
0 commit comments