如何将 Algol 68 Genia 语言转换为 c++语言

发布于 2024-10-19 15:56:04 字数 323 浏览 5 评论 0原文

建议我如何将以下代码更改为 C++ 代码:

ROOTPROC VarUse
PROC VarUse
ROOT Cfile;
1 {
2 [
3 (?NameRef
4 (IF (AND (HAS-TYPE $parent Assignment) (IS-EQUAL $slot ``lhs''))
5 (THEN (PRINT stdout "Variable %s defined at %s" $token $location))
6 (ELSE (PRINT stdout "Name %s accessed at %s" $token $location))))]
7 }

Suggest me on how to change the following code into c++ code:

ROOTPROC VarUse
PROC VarUse
ROOT Cfile;
1 {
2 [
3 (?NameRef
4 (IF (AND (HAS-TYPE $parent Assignment) (IS-EQUAL $slot ``lhs''))
5 (THEN (PRINT stdout "Variable %s defined at %s" $token $location))
6 (ELSE (PRINT stdout "Name %s accessed at %s" $token $location))))]
7 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坏尐絯 2024-10-26 15:56:04

显然这个代码是“Algol 68 Genie”。这段代码并不完整,但从表面上看,它必须等于下一个 C++ 代码:

if(parent->hasType('Assigment') and slot == lhs)
{
   std::cout << "Variable " << token << " defined at " << location << std::endl;
}
else
{
   std::cout << "Name " << token << " accessed at " << location << std::endl;
}

像 HAS-TYPE 这样的表达式没有直接的类似物。有关此语言的更多信息,请参阅 Algol 68 Genie

Apparently this code is "Algol 68 Genie". This code is not complete, but on the face of it must be equal next c++ code:

if(parent->hasType('Assigment') and slot == lhs)
{
   std::cout << "Variable " << token << " defined at " << location << std::endl;
}
else
{
   std::cout << "Name " << token << " accessed at " << location << std::endl;
}

Expressions like HAS-TYPE not have direct analogue. More about this language is written in the Algol 68 Genie

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文