Langserver fixes, vol 2 (#7401)

This commit is contained in:
Erki
2019-11-15 23:42:25 +02:00
committed by Werner
parent 444c0d5ea5
commit ff41b92e97
39 changed files with 100 additions and 159 deletions

View File

@@ -53,10 +53,9 @@
if(/token/word)
return new/node/expression/value/variable(T.value)
if(/token/accessor)
var
token/accessor/A=T
node/expression/value/variable/E//=new(A.member)
stack/S=new()
var/token/accessor/A = T
var/node/expression/value/variable/E
var/stack/S = new()
while(istype(A.object, /token/accessor))
S.Push(A)
A=A.object
@@ -181,11 +180,10 @@
- <ParseParamExpression()>
*/
ParseExpression(list/end=list(/token/end), list/ErrChars=list("{", "}"))
var/stack
opr=new
val=new
var/stack/opr = new
var/stack/val = new
src.expecting=VALUE
for()
while (1)
if(EndOfExpression(end))
break
if(istype(curToken, /token/symbol) && ErrChars.Find(curToken.value))
@@ -278,7 +276,7 @@
NextToken() //skip open parenthesis, already found
var/loops = 0
for()
while (1)
loops++
if(loops>=1000)
CRASH("Something TERRIBLE has gone wrong in ParseFunctionExpression ;__;")
@@ -311,4 +309,4 @@
- <ParseExpression()>
*/
ParseParamExpression()
return ParseExpression(list(",", ")"))
return ParseExpression(list(",", ")"))

View File

@@ -134,7 +134,7 @@ var/const/Represents a special statement in the code triggered by a keyword.
parser.NextToken()
if(!parser.CheckToken("(", /token/symbol))
return KW_FAIL
for() //for now parameters can be separated by whitespace - they don't need a comma in between
while (1) //for now parameters can be separated by whitespace - they don't need a comma in between
if(istype(parser.curToken, /token/symbol))
switch(parser.curToken.value)
if(",")

View File

@@ -172,7 +172,7 @@
if(!CheckToken("(", /token/symbol)) //Check for and skip open parenthesis
return
var/loops = 0
for()
while (1)
loops++
if(loops>=6000)
CRASH("Something TERRIBLE has gone wrong in ParseFunctionStatement ;__;")
@@ -186,4 +186,4 @@
return
var/node/expression/P=ParseParamExpression()
stmt.parameters+=P
if(istype(curToken, /token/symbol) && curToken.value==",") NextToken()
if(istype(curToken, /token/symbol) && curToken.value==",") NextToken()

View File

@@ -153,8 +153,7 @@
start - The character used to start the string.
*/
ReadString(start)
var
buf
var/buf
for(, codepos <= lentext(code), codepos++)//codepos to lentext(code))
var/char=copytext(code, codepos, codepos+1)
switch(char)
@@ -189,9 +188,8 @@
Reads characters separated by an item in <delim> into a token.
*/
ReadWord()
var
char=copytext(code, codepos, codepos+1)
buf
var/char=copytext(code, codepos, codepos+1)
var/buf
while(!delim.Find(char) && codepos<=lentext(code))
buf+=char
char=copytext(code, ++codepos, codepos+1)
@@ -206,9 +204,8 @@
Reads a symbol into a token.
*/
ReadSymbol()
var
char=copytext(code, codepos, codepos+1)
buf
var/char=copytext(code, codepos, codepos+1)
var/buf
while(options.symbols.Find(buf+char))
buf+=char
@@ -223,10 +220,9 @@
Reads a number into a token.
*/
ReadNumber()
var
char=copytext(code, codepos, codepos+1)
buf
dec=0
var/char = copytext(code, codepos, codepos+1)
var/buf
var/dec = 0
while(options.IsDigit(char) || (char=="." && !dec))
if(char==".") dec=1
@@ -246,14 +242,13 @@
*/
ReadComment()
var
char=copytext(code, codepos, codepos+1)
nextchar=copytext(code, codepos+1, codepos+2)
charstring = char+nextchar
comm = 1
var/char = copytext(code, codepos, codepos+1)
var/nextchar = copytext(code, codepos+1, codepos+2)
var/charstring = char+nextchar
var/comm = 1
// 1: single-line comment
// 2: multi-line comment
expectedend = 0
var/expectedend = 0
if(charstring == "//" || charstring == "/*")
if(charstring == "/*")