X Tutup
Skip to content

Commit 9156cab

Browse files
committed
sVB 3.5.8.3
1 parent 145be64 commit 9156cab

File tree

26 files changed

+1023
-473
lines changed

26 files changed

+1023
-473
lines changed

LangServices/CompletionProvider.vb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,6 @@ Namespace Microsoft.SmallVisualBasic.LanguageService
803803

804804
End Function
805805

806-
807-
808806
Private Shared Function IsPrevSeparator(
809807
currentLine As Integer,
810808
symbole As String,
@@ -943,6 +941,9 @@ Namespace Microsoft.SmallVisualBasic.LanguageService
943941
adornment.ModifySpans(adornmentSpan, replaceSpan)
944942
End If
945943

944+
ElseIf textChange.Delta < 0 Then
945+
ShowCompletionAdornment(e.After, newEnd)
946+
946947
ElseIf newText <> "" Then
947948
Dim c = newText.Last
948949
If Char.IsLetter(c) OrElse c = "_" Then
@@ -1106,7 +1107,7 @@ Namespace Microsoft.SmallVisualBasic.LanguageService
11061107
Dim txt = currentToken.LCaseText
11071108
If txt <> "" AndAlso controlNames IsNot Nothing Then
11081109
Dim x = currentToken.Text
1109-
Dim txt2 = UCase(x(0)) & If(x.Length > 1, x.Substring(0), "")
1110+
Dim txt2 = UCase(x(0)) & If(x.Length > 1, x.Substring(1), "")
11101111
Dim controls = From name In controlNames
11111112
Where name(0) <> "("c AndAlso (
11121113
(forHelp AndAlso name.ToLower() = txt) OrElse

SBCompiler/SBCompiler/Statements/SubroutineCallStatement.vb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,21 @@ Namespace Microsoft.SmallVisualBasic.Statements
6060
Dim subName = Name.Text
6161
Dim subName2 = subName.ToLower
6262
If Name.Contains(line, column, True) Then
63-
bag.CompletionItems.Add(
64-
New CompletionItem() With {
65-
.DisplayName = subName,
66-
.ItemType = CompletionItemType.SubroutineName,
67-
.Key = subName,
68-
.ReplacementText = subName,
69-
.DefinitionIdintifier = (From subroutine In bag.SymbolTable.Subroutines
70-
Where subroutine.Key = subName2).FirstOrDefault.Value
71-
}
72-
)
73-
63+
Dim subTokens = (From subroutine In bag.SymbolTable.Subroutines
64+
Where subroutine.Key.StartsWith(subName2))
65+
66+
For Each subToken In subTokens
67+
subName = subToken.Value.Text
68+
bag.CompletionItems.Add(
69+
New CompletionItem() With {
70+
.DisplayName = subName,
71+
.ItemType = CompletionItemType.SubroutineName,
72+
.Key = subName,
73+
.ReplacementText = subName,
74+
.DefinitionIdintifier = subToken.Value
75+
}
76+
)
77+
Next
7478
ElseIf Args IsNot Nothing AndAlso Args.Count > 0 AndAlso line >= Args(0).StartToken.Line Then
7579
CompletionHelper.FillExpressionItems(bag)
7680
CompletionHelper.FillSubroutines(bag, True)

Samples/Sahla Programming Language/Sahla-En/Global.sb

Lines changed: 153 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ _Line = "Line"
5555
_Read = "Read"
5656
_Text = "Text"
5757
_Number = "Number"
58+
_Move = "Move"
59+
_Turn = "Turn"
60+
_Speed = "Speed"
61+
_Turtle = "Turtle"
5862
_Random = "Random"
5963
_Wait = "Wait"
6064
_Sound = "Play"
@@ -72,12 +76,16 @@ BasicWords = {
7276
_True, _False, _If, _Else, _ElseIf, _EndIf, _And, _Or,
7377
_While, _Wend, _For, _To, _Step, _Next, _ExitLoop,
7478
_Write, _Line, _Read, _Text, _Number,
79+
_Move, _Turn, _Speed, _Turtle,
7580
_Wait, _Random, _Sound, _Beep, _Bell, _Ding, _Click, _Chime
7681
}
7782

7883
CommandsCompletionList = {
7984
_Write,
8085
_Write & " " & _Line,
86+
_Move & " " & _Turtle,
87+
_Turn & " " & _Turtle,
88+
_Speed & " " & _Turtle,
8189
_If, _Else, _ElseIf, _EndIf,
8290
_While, _Wend, _For, _Next, _ExitLoop,
8391
_Wait,
@@ -146,6 +154,10 @@ _EnLine = "Line"
146154
_EnRead = "Read"
147155
_EnText = "Text"
148156
_EnNumber = "Number"
157+
_EnMove = "Move"
158+
_EnTurn = "Turn"
159+
_EnSpeed = "Speed"
160+
_EnTurtle = "Turtle"
149161
_EnRandom = "Random"
150162
_EnWait = "Wait"
151163
_EnSound = "Play"
@@ -275,6 +287,7 @@ EndSub
275287
Sub Run()
276288
Terminated = False
277289
TW.Clear()
290+
TW.Hide()
278291
Vars = {}
279292
Stack.Clear(WhileStack)
280293
Stack.Clear(ForStack)
@@ -284,7 +297,7 @@ Sub Run()
284297
LineIndex = 1
285298
statementsCount = Statements.Count
286299

287-
While LineIndex <= statementsCount
300+
While Terminated = False And LineIndex <= statementsCount
288301
Tokenize(Statements[LineIndex], LineIndex, _CommentSymbol, True)
289302
ExecuteLine()
290303
If LineIndex <= Statements.Count Then
@@ -298,7 +311,6 @@ Sub Run()
298311
Wend
299312

300313
Terminate(_ProEnd, False)
301-
EditorTextBox.Focus()
302314
EndSub
303315

304316
Sub EndProgram()
@@ -307,24 +319,33 @@ EndSub
307319

308320
Sub Terminate(msg, isError)
309321
If isError Then
310-
TW.AppendFormatted(
311-
Chars.Lf & msg,
312-
"", 20,
313-
True, False, False,
314-
Colors.Red, Colors.Yellow
315-
)
316-
Else
322+
If GW.IsClosed = False Then
323+
GW.ShowMessage(msg, "Error")
324+
GW.Close()
325+
Else
326+
TW.AppendFormatted(
327+
Chars.Lf & msg,
328+
"", 20,
329+
True, False, False,
330+
Colors.Red, Colors.Yellow
331+
)
332+
EndIf
333+
334+
ElseIf GW.IsClosed Then
317335
TW.Write(Chars.Lf & msg)
336+
TW.PauseWithoutMessage()
337+
TW.Close()
338+
339+
Else
340+
TW.Close()
341+
GW.Show()
318342
EndIf
319-
320-
TW.PauseWithoutMessage()
321-
TW.Close()
322343
EndSub
323344

324345
Sub ExecuteLine()
325346
tokensCount = Tokens.Count
326347

327-
If tokensCount = 0 Or TW.IsClosed Then
348+
If tokensCount = 0 Or Terminated Or TW.IsClosed Then
328349
Return
329350
EndIf
330351

@@ -368,7 +389,7 @@ Sub ExecuteLine()
368389
EndIf
369390
EndIf
370391

371-
If TW.IsClosed Then
392+
If Terminated Or TW.IsClosed Then
372393
Return
373394
EndIf
374395
TW.WriteLine(FixBool(msg))
@@ -381,12 +402,51 @@ Sub ExecuteLine()
381402
Return
382403
EndIf
383404

384-
If TW.IsClosed Then
405+
If Terminated Or TW.IsClosed Then
385406
Return
386407
EndIf
387408
TW.Write(FixBool(result[1]))
388409
EndIf
389410

411+
ElseIf Text.AreEquals(command, _Move, False) Or
412+
Text.AreEquals(command, _Turn, False) Or
413+
Text.AreEquals(command, _Speed, False) Then
414+
nextCommand = Tokens[2][3]
415+
If tokensCount = 1 Or Text.AreEquals(nextCommand, _Turtle, False) = False Then
416+
ReportError("'" & _Turtle & "'" & _IsExpected, LineIndex, 1)
417+
Else
418+
If tokensCount = 2 Then
419+
arg = "?"
420+
Else
421+
result = EvaluateExpression(3)
422+
arg = result[1]
423+
nextPos = result[2]
424+
If nextPos < tokensCount Then
425+
ReportError("'" & Tokens[nextPos][3] & _Unexpected, LineIndex, nextPos)
426+
Return
427+
EndIf
428+
EndIf
429+
430+
If Terminated Or TW.IsClosed Then
431+
Return
432+
ElseIf Text.AreEquals(command, _Move, False) Then
433+
If arg = "?" Then
434+
arg = 100
435+
EndIf
436+
Turtle.Move(arg)
437+
ElseIf Text.AreEquals(command, _Turn, False) Then
438+
If arg = "?" Then
439+
arg = 90
440+
EndIf
441+
Turtle.Turn(arg)
442+
Else
443+
If arg = "?" Then
444+
arg = 25
445+
EndIf
446+
Turtle.Speed = arg
447+
EndIf
448+
EndIf
449+
390450
ElseIf Text.AreEquals(command, _For, False) Then
391451
ProcessForLoopHeader()
392452

@@ -1058,7 +1118,7 @@ Function ParseTerm(pos)
10581118
EndFunction
10591119

10601120
Function ParseFactor(pos)
1061-
If TW.IsClosed Then
1121+
If Terminated Or TW.IsClosed Then
10621122
Return {}
10631123
EndIf
10641124

@@ -1148,8 +1208,7 @@ Sub ReportError(msg, line, tokenIndex)
11481208
Array.Join({
11491209
_ErrorAtToken, tokenIndex, " ",
11501210
_ErrorAtLine, line, ":",
1151-
Chars.CrLf, msg,
1152-
Chars.CrLf, _ProEnd
1211+
Chars.CrLf, msg
11531212
}, ""
11541213
), True
11551214
)
@@ -1729,6 +1788,18 @@ Sub InitTransTokes(forwardConversion)
17291788
OrgTokes[_EnNumber] = _Number
17301789
DestTokes[_EnNumber] = _EnNumber
17311790

1791+
OrgTokes[_EnMove] = _Move
1792+
DestTokes[_EnMove] = _EnMove
1793+
1794+
OrgTokes[_EnTurn] = _Turn
1795+
DestTokes[_EnTurn] = _EnTurn
1796+
1797+
OrgTokes[_EnSpeed] = _Speed
1798+
DestTokes[_EnSpeed] = _EnSpeed
1799+
1800+
OrgTokes[_EnTurtle] = _Turtle
1801+
DestTokes[_EnTurtle] = _EnTurtle
1802+
17321803
OrgTokes[_EnRandom] = _Random
17331804
DestTokes[_EnRandom] = _EnRandom
17341805

@@ -1821,6 +1892,19 @@ Sub InitTransTokes(forwardConversion)
18211892
OrgTokes[_EnNumber] = _EnNumber
18221893
DestTokes[_EnNumber] = _Number
18231894

1895+
1896+
OrgTokes[_EnMove] = _EnMove
1897+
DestTokes[_EnMove] = _Move
1898+
1899+
OrgTokes[_EnTurn] = _EnTurn
1900+
DestTokes[_EnTurn] = _Turn
1901+
1902+
OrgTokes[_EnSpeed] = _EnSpeed
1903+
DestTokes[_EnSpeed] = _Speed
1904+
1905+
OrgTokes[_EnTurtle] = _EnTurtle
1906+
DestTokes[_EnTurtle] = _Turtle
1907+
18241908
OrgTokes[_EnRandom] = _EnRandom
18251909
DestTokes[_EnRandom] = _Random
18261910

@@ -2023,6 +2107,57 @@ Function ConvertLine()
20232107
Return "TW.Write(" & result[1] & ")"
20242108
EndIf
20252109

2110+
ElseIf Text.AreEquals(command, OrgTokes[_EnMove], False) Then
2111+
nextCommand = Tokens[2][3]
2112+
If Text.AreEquals(nextCommand, OrgTokes[_EnTurtle], False) Then
2113+
If tokensCount = 2 Then
2114+
If ConvertToEnSahla Then
2115+
Return DestTokes[_EnMove] & " " & DestTokes[_EnTurtle]
2116+
EndIf
2117+
Return "Turtle.Move(100)"
2118+
Else
2119+
result = BuildExpressionText(3)
2120+
If ConvertToEnSahla Then
2121+
Return DestTokes[_EnMove] & " " & DestTokes[_EnTurtle] & " " & result[1]
2122+
EndIf
2123+
Return "Turtle.Move(" & result[1] & ")"
2124+
EndIf
2125+
EndIf
2126+
2127+
ElseIf Text.AreEquals(command, OrgTokes[_EnTurn], False) Then
2128+
nextCommand = Tokens[2][3]
2129+
If Text.AreEquals(nextCommand, OrgTokes[_EnTurtle], False) Then
2130+
If tokensCount = 2 Then
2131+
If ConvertToEnSahla Then
2132+
Return DestTokes[_EnTurn] & " " & DestTokes[_EnTurtle]
2133+
EndIf
2134+
Return "Turtle.Turn(90)"
2135+
Else
2136+
result = BuildExpressionText(3)
2137+
If ConvertToEnSahla Then
2138+
Return DestTokes[_EnTurn] & " " & DestTokes[_EnTurtle] & " " & result[1]
2139+
EndIf
2140+
Return "Turtle.Turn(" & result[1] & ")"
2141+
EndIf
2142+
EndIf
2143+
2144+
ElseIf Text.AreEquals(command, OrgTokes[_EnSpeed], False) Then
2145+
nextCommand = Tokens[2][3]
2146+
If Text.AreEquals(nextCommand, OrgTokes[_EnTurtle], False) Then
2147+
If tokensCount = 2 Then
2148+
If ConvertToEnSahla Then
2149+
Return DestTokes[_EnSpeed] & " " & DestTokes[_EnTurtle]
2150+
EndIf
2151+
Return "Turtle.Speed = 25"
2152+
Else
2153+
result = BuildExpressionText(3)
2154+
If ConvertToEnSahla Then
2155+
Return DestTokes[_EnSpeed] & " " & DestTokes[_EnTurtle] & " " & result[1]
2156+
EndIf
2157+
Return "Turtle.Speed = " & result[1]
2158+
EndIf
2159+
EndIf
2160+
20262161
ElseIf Text.AreEquals(command, OrgTokes[_EnFor], False) Then
20272162
Return ConvertForLoopHeader()
20282163

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Times New Roman
2+
20
3+
False
4+
False
5+
False
6+
#FF000000
7+
#FFFFFFFF
8+
False
9+
True
10+
False
11+
Speed Turtle 50
12+
Write "Enter polygon count: "
13+
polygons = Read Number
14+
Write "Enter side count: "
15+
sides = Read Number
16+
Write "Enter side length: "
17+
length = Read Number
18+
19+
For p = 1 To polygons
20+
' Draw Polygon
21+
For m = 1 To sides
22+
Move Turtle length
23+
Turn Turtle 360 / sides
24+
Next m
25+
' rotate turtle to roteate the next polygon
26+
Turn Turtle 360 / polygons
27+
Next p

0 commit comments

Comments
 (0)
X Tutup