1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 08:51:22 +00:00

Merge pull request #120 from QB64Team/IdeTweaks

More fixes [skip-ci]
This commit is contained in:
Fellippe Heitor 2021-01-29 02:34:32 -03:00 committed by GitHub
commit 8f54082687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5110,6 +5110,7 @@ DO
controllevel = controllevel - 1
END IF
IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = "SUB" ELSE secondelement$ = "FUNCTION"
l$ = firstelement$ + sp + secondelement$
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
@ -7360,9 +7361,10 @@ DO
IF secondelement$ = "SUB" THEN sf = 2
IF sf THEN
IF LEN(subfunc) = 0 THEN a$ = "EXIT " + secondelement$ + " must be used within a SUB/FUNCTION": GOTO errmes
IF LEN(subfunc) = 0 THEN a$ = "EXIT " + secondelement$ + " must be used within a " + secondelement$: GOTO errmes
PRINT #12, "goto exit_subfunc;"
IF LEFT$(subfunc, 4) = "SUB_" THEN secondelement$ = "SUB" ELSE secondelement$ = "FUNCTION"
l$ = firstelement$ + sp + secondelement$
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
GOTO finishedline
@ -23766,12 +23768,12 @@ FUNCTION Evaluate_Expression$ (e$)
END IF
LOOP
s = Eval_E - c + 1
IF s < 1 THEN Evaluate_Expression$ = "ERROR -- BAD () Count": EXIT SUB
IF s < 1 THEN Evaluate_Expression$ = "ERROR -- BAD () Count": EXIT FUNCTION
eval$ = " " + MID$(exp$, s, Eval_E - s) + " " 'pad with a space before and after so the parser can pick up the values properly.
ParseExpression eval$
eval$ = LTRIM$(RTRIM$(eval$))
IF LEFT$(eval$, 5) = "ERROR" THEN Evaluate_Expression$ = eval$: EXIT SUB
IF LEFT$(eval$, 5) = "ERROR" THEN Evaluate_Expression$ = eval$: EXIT FUNCTION
exp$ = DWD(LEFT$(exp$, s - 2) + eval$ + MID$(exp$, Eval_E + 1))
IF MID$(exp$, 1, 1) = "N" THEN MID$(exp$, 1) = "-"
END IF
@ -23781,7 +23783,7 @@ FUNCTION Evaluate_Expression$ (e$)
c = c + 1
SELECT CASE MID$(exp$, c, 1)
CASE "0" TO "9", ".", "-" 'At this point, we should only have number values left.
CASE ELSE: Evaluate_Expression$ = "ERROR - Unknown Diagnosis: (" + exp$ + ") ": EXIT SUB
CASE ELSE: Evaluate_Expression$ = "ERROR - Unknown Diagnosis: (" + exp$ + ") ": EXIT FUNCTION
END SELECT
LOOP UNTIL c >= LEN(exp$)
@ -24364,6 +24366,41 @@ SUB PreParse (e$)
END IF
LOOP UNTIL l = 0
'replace existing CONST values
sep$ = "()+-*/\><=^"
FOR i2 = 0 TO constlast
thisConstName$ = constname(i2)
FOR replaceConstPass = 1 TO 2
found = 0
DO
found = INSTR(found + 1, UCASE$(t$), thisConstName$)
IF found THEN
IF found > 1 THEN
IF INSTR(sep$, MID$(t$, found - 1, 1)) = 0 THEN _CONTINUE
END IF
IF found + LEN(thisConstName$) <= LEN(t$) THEN
IF INSTR(sep$, MID$(t$, found + LEN(thisConstName$), 1)) = 0 THEN _CONTINUE
END IF
t = consttype(i2)
IF t AND ISSTRING THEN
r$ = conststring(i2)
i4 = _INSTRREV(r$, ",")
r$ = LEFT$(r$, i4 - 1)
ELSE
IF t AND ISFLOAT THEN
r$ = STR$(constfloat(i2))
r$ = N2S(r$)
ELSE
IF t AND ISUNSIGNED THEN r$ = STR$(constuinteger(i2)) ELSE r$ = STR$(constinteger(i2))
END IF
END IF
t$ = LEFT$(t$, found - 1) + _TRIM$(r$) + MID$(t$, found + LEN(thisConstName$))
END IF
LOOP UNTIL found = 0
thisConstName$ = constname(i2) + constnamesymbol(i2)
NEXT
NEXT
uboundPP_TypeMod = TotalPrefixedPP_TypeMod
IF qb64prefix_set = 1 THEN uboundPP_TypeMod = TotalPP_TypeMod
FOR j = 1 TO uboundPP_TypeMod
@ -24392,8 +24429,6 @@ SUB PreParse (e$)
LOOP
NEXT
'Check for bad operators before a ( bracket
l = 0
DO
@ -24441,37 +24476,6 @@ SUB PreParse (e$)
END IF
LOOP UNTIL l = 0 OR l = LEN(t$) 'last symbol is a bracket
'replace existing CONST values
sep$ = "()+-*/\><=^"
FOR i2 = 0 TO constlast
found = 0
DO
found = INSTR(found + 1, UCASE$(t$), constname(i2))
IF found THEN
IF found > 1 THEN
IF INSTR(sep$, MID$(t$, found - 1, 1)) = 0 THEN _CONTINUE
END IF
IF found + LEN(constname(i2)) <= LEN(t$) THEN
IF INSTR(sep$, MID$(t$, found + LEN(constname(i2)), 1)) = 0 THEN _CONTINUE
END IF
t = consttype(i2)
IF t AND ISSTRING THEN
r$ = conststring(i2)
i4 = _INSTRREV(r$, ",")
r$ = LEFT$(r$, i4 - 1)
ELSE
IF t AND ISFLOAT THEN
r$ = STR$(constfloat(i2))
r$ = N2S(r$)
ELSE
IF t AND ISUNSIGNED THEN r$ = STR$(constuinteger(i2)) ELSE r$ = STR$(constinteger(i2))
END IF
END IF
t$ = LEFT$(t$, found - 1) + _TRIM$(r$) + MID$(t$, found + LEN(constname(i2)))
END IF
LOOP UNTIL found = 0
NEXT
'Turn all &H (hex) numbers into decimal values for the program to process properly
l = 0
DO
@ -24570,7 +24574,7 @@ FUNCTION N2S$ (exp$) 'scientific Notation to String
dp = INSTR(t$, "D+"): dm = INSTR(t$, "D-")
ep = INSTR(t$, "E+"): em = INSTR(t$, "E-")
check1 = SGN(dp) + SGN(dm) + SGN(ep) + SGN(em)
IF check1 < 1 OR check1 > 1 THEN N2S = exp$: EXIT SUB 'If no scientic notation is found, or if we find more than 1 type, it's not SN!
IF check1 < 1 OR check1 > 1 THEN N2S = exp$: EXIT FUNCTION 'If no scientic notation is found, or if we find more than 1 type, it's not SN!
SELECT CASE l 'l now tells us where the SN starts at.
CASE IS < dp: l = dp
@ -24607,7 +24611,7 @@ FUNCTION N2S$ (exp$) 'scientific Notation to String
END SELECT
N2S$ = sign$ + l$
END SUB
END FUNCTION
FUNCTION QuotedFilename$ (f$)
@ -25185,7 +25189,7 @@ FUNCTION EvalPreIF (text$, err$)
SELECT CASE a$
CASE " " 'ignore spaces
CASE "=", "<", ">"
IF a$ = firstsymbol$ THEN err$ = "Duplicate operator (" + a$ + ")": EXIT SUB
IF a$ = firstsymbol$ THEN err$ = "Duplicate operator (" + a$ + ")": EXIT FUNCTION
second = i: secondsymbol$ = a$
CASE ELSE 'we found a symbol we don't recognize
EXIT FOR
@ -25332,7 +25336,7 @@ FUNCTION EvalPreIF (text$, err$)
NEXT
END IF
END SUB
END FUNCTION
FUNCTION VerifyNumber (text$)
t$ = LTRIM$(RTRIM$(text$))