我想创建自己的编程语言.也许不是从头开始编程语言,但可能是基于另一种语言.
我听说过Yacc.所以,我安装了Flex和Bison.但我不明白如何使用它编译.我已经Hello world在其中制作了该项目,但我如何在其中制作编译器?
有没有简单的方法来创建一个小的编程语言,我听说过翻译一种语言,例如,Write()并使计算机理解它Print().
这有可能吗?
compiler-construction yacc programming-languages language-design bison
我在c#中遇到以下错误:此代码"并非所有代码路径都返回值"我正在尝试使用它创建编程语言.任何帮助是极大的赞赏.
private Expr ParseExpr()
{
if (this.index == this.tokens.Count)
{
throw new System.Exception("expected expression, got EOF");
}
if (this.tokens[this.index] is Text.StringBuilder)
{
string Value = ((Text.StringBuilder)this.tokens[this.index++]).ToString();
StringLiteral StringLiteral = new StringLiteral();
StringLiteral.Value = Value;
}
else if (this.tokens[this.index] is int)
{
int intvalue = (int)this.tokens[this.index++];
IntLiteral intliteral = new IntLiteral();
intliteral.Value = intvalue;
return intliteral;
}
else if (this.tokens[this.index] is string)
{
string Ident = (string)this.tokens[this.index++];
Variable var = new Variable();
var.Ident = Ident;
return var;
}
else
{
throw …Run Code Online (Sandbox Code Playgroud)