0

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 }
Denis Kreshikhin
  • 8,856
  • 9
  • 52
  • 84
eklmp
  • 201
  • 3
  • 9
  • Please use code formatting. See the faq on how to do that. – fingerprint211b Mar 02 '11 at 12:12
  • I have no idea what Genoa is, so perhaps you can describe what the code does. What have you tried? – Mark Loeser Mar 02 '11 at 16:08
  • @Denis: It looks like this was written in [Genoa](http://stackoverflow.com/questions/5166096/which-language-is-the-following-program-written-in), not [Algol68](http://algol68.sourceforge.net/) – NevilleDNZ Feb 12 '13 at 19:38

1 Answers1

1

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

Denis Kreshikhin
  • 8,856
  • 9
  • 52
  • 84