Skip to content

Commit

Permalink
'concat no whiteSpace': thisE.text = ' '; example: v:="str"var -> `…
Browse files Browse the repository at this point in the history
…v:="str" var`; #19; githubPages
  • Loading branch information
FuPeiJiang committed Jul 25, 2021
1 parent 1db0c6b commit a050bee
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/ahkParser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/modifyEverythingToV2.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mocha/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('toV2(text)',function() {
,String.raw`SQLiteDLL:=IniRead(A_ScriptDir "\SQLiteDB.ini","Main","DllPath",SQLiteDLL ); old`)
})
doIt('WinGetTitle, OutputVar, A','OutputVar:=WinGetTitle("A")')
doIt('v:=spr " h"ySep " w"3*xSep " v" "t_" c "_" r','v:=spr " h" ySep " w" 3*xSep " v" "t_" c "_" r')

})

Expand Down
4 changes: 2 additions & 2 deletions src/convertTov2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import modifyEverythingToV2 from './modifyEverythingToV2'


const content: Buffer =
fs.readFileSync('v2tests/hotkey return to brackets.ahk')
// fs.readFileSync('tests3/SplashyTest gui add.ahk')
// fs.readFileSync('v2tests/hotkey return to brackets.ahk')
fs.readFileSync('tests3/SplashyTest gui add.ahk')
// fs.readFileSync('v2tests/IniRead.ahk')
// fs.readFileSync('tests3/new class.ahk')
// fs.readFileSync('tests3/Incorrect quoting of parameters #6.ahk')
Expand Down
2 changes: 2 additions & 0 deletions src/modifyEverythingToV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ export default (everything: ExtendedEverythingType,is_AHK_H = true): string => {
//and to not skip the '%START %Var%'
} else if (eType === 'String') {
thisE.text = `"${thisE.text.slice(1,-1).replace(/""/g,'`"')}"`
} else if (eType === 'concat no whiteSpace') {
thisE.text = ' '
} else if (anyCommand[eType]) {
//if breakOrContinue, if is number, don't surround with quotes
switch (thisE.text.toLowerCase()) {
Expand Down
22 changes: 15 additions & 7 deletions src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2167,13 +2167,21 @@ export default (content: string,literalDoubleQuoteInContinuation = false): Every
//if the next thing is expr, it is a concat
// if char before is whiteSpace concat
const everythingConcatIndex = everything.length - 1
if (i === lineWhereCanConcat && whiteSpaceObj[lines[i][c - 1]] && findExpression()) {
// const concatWhiteSpaces = lines[concatLineBak].slice(beforeConcatBak, afterConcat)
// d(`concat "${concatWhiteSpaces}" ${concatWhiteSpaces.length}LENGHT ${beforeConcatBak + 1} line ${concatLineBak + 1}`)
// I just have to replace the last whiteSpace with concat
everything[everythingConcatIndex].type = 'concat'
// everything.push({type: 'concat', text:concatWhiteSpaces,i1: concatLineBak, c1: beforeConcatBak,c2:afterConcat})
return true
if (i === lineWhereCanConcat) {
if (whiteSpaceObj[lines[i][c - 1]] && findExpression()) {
everything[everythingConcatIndex].type = 'concat'
// const concatWhiteSpaces = lines[concatLineBak].slice(beforeConcatBak, afterConcat)
// d(`concat "${concatWhiteSpaces}" ${concatWhiteSpaces.length}LENGHT ${beforeConcatBak + 1} line ${concatLineBak + 1}`)
// I just have to replace the last whiteSpace with concat
// everything.push({type: 'concat', text:concatWhiteSpaces,i1: concatLineBak, c1: beforeConcatBak,c2:afterConcat})
return false
} else if (everything[everythingConcatIndex].type === 'String') {
const iBak = i,cBak = c
if (findExpression()) {
everything.splice(everythingConcatIndex + 1,0,{type:'concat no whiteSpace',text:'',i1:iBak,c1:cBak,c2:cBak})
return false
}
}
}

if (insideContinuation) {
Expand Down
5 changes: 4 additions & 1 deletion tests3/SplashyTest gui add.ahk
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
; v:="str"3
; v:=var "str"var
; v:="str"var
v:=spr " h"ySep " w"3*xSep " v" "t_" c "_" r
; gui, Test: add, text, % spr " h"ySep " w"3*xSep " v" "t_" c "_" r
v:=spr " h"ySep " w"3*xSep " v" "t_" c "_" r

0 comments on commit a050bee

Please sign in to comment.