fix: 修复编译中的一些小问题 (#52)
Co-authored-by: Lan_G <2911328695@qq.com> Reviewed-on: PostGuard/Canon#52
This commit is contained in:
parent
366991046a
commit
d381f56e1d
|
@ -15,15 +15,18 @@ public class AddOperator : NonTerminatedSyntaxNode
|
|||
|
||||
public override void GenerateCCode(CCodeBuilder builder)
|
||||
{
|
||||
var operatorType = Children[0].Convert<TerminatedSyntaxNode>().Token.
|
||||
Convert<OperatorSemanticToken>().OperatorType;
|
||||
if (operatorType == OperatorType.Plus)
|
||||
var token = Children[0].Convert<TerminatedSyntaxNode>().Token;
|
||||
if (token.TokenType == SemanticTokenType.Operator)
|
||||
{
|
||||
builder.AddString(" +");
|
||||
}
|
||||
else if (operatorType == OperatorType.Minus)
|
||||
{
|
||||
builder.AddString(" -");
|
||||
var operatorType = token.Convert<OperatorSemanticToken>().OperatorType;
|
||||
if (operatorType == OperatorType.Plus)
|
||||
{
|
||||
builder.AddString(" +");
|
||||
}
|
||||
else if (operatorType == OperatorType.Minus)
|
||||
{
|
||||
builder.AddString(" -");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MultiplyOperator : NonTerminatedSyntaxNode
|
|||
}
|
||||
else if (operatorType == OperatorType.Divide)
|
||||
{
|
||||
//实数除法,需要将操作数强转为float
|
||||
//实数除法,需要将操作数强转为double
|
||||
builder.AddString(" /(double)");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ProgramStruct : NonTerminatedSyntaxNode
|
|||
|
||||
public override void GenerateCCode(CCodeBuilder builder)
|
||||
{
|
||||
builder.AddString("#include <PascalCoreLib.h> #include <stdbool.h>");
|
||||
builder.AddString("#include <stdbool.h>");
|
||||
Body.GenerateCCode(builder);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user