Closed MEMESCOEP closed 3 years ago
Nevermind, just required some changes to the parser
For anyone who is interested, here is the input block:
` # "INPUT" ident elif self.checkToken(TokenType.INPUT): self.nextToken()
# If variable doesn't already exist, declare it.
if self.curToken.text not in self.symbols:
self.symbols.add(self.curToken.text)
self.emitter.headerLine("char " + self.curToken.text + ";")
# Emit scanf but also validate the input. If invalid, set the variable to 0 and clear the input.
self.emitter.emitLine("scanf(\"%" + "f\", &" + self.curToken.text + ")")
#self.emitter.emitLine(self.curToken.text + " = 0;")
#self.emitter.emit("scanf(\"%")
self.emitter.emitLine("*s\");")
#self.emitter.emitLine("}")
self.match(TokenType.IDENT)
# This is not a valid statement. Error!
else:
self.abort("Invalid statement at " + self.curToken.text + " (" + self.curToken.kind.name + ")")`
Hello, I am trying to print what the user types. This is what I have done:
`PRINT "Enter a string!" INPUT lmao
PRINT "You typed: " PRINT lmao`
but this only prints an integer! Is it possible to print a string from user input?