#include "stdafx.h" #include "example.h" #include "inp.h" #include "lex.h" #include "out.h" #include using namespace std; void PutStd (string s) { PutStr (const_cast (s.c_str ())); } string GetIdent () { string result = IdentVal; CheckSymbol (IDENT); return result; } string GetNumber () { string result = NumVal; CheckSymbol (NUM); return result; } string GetFloat () { string result = NumVal; CheckSymbol (FLT); return result; } string GetString () { string result = StrVal; CheckSymbol (STR); return result; } string GetChar () { string result = string (1, ChrVal); CheckSymbol (CHR); return result; } void object () { // if (sy != IDENT) // Error ("Identifier expected"); // NextSymbol (); string type = GetIdent (); PutStd ("begin of " + type); PutEol (); Indent (); CheckSymbol (LBRACE); while (sy != RBRACE) { string name = GetIdent (); CheckSymbol (ASSIGN); string value = ""; if (sy == IDENT) value = GetIdent (); else if (sy == NUM) value = GetNumber (); else if (sy == FLT) value = GetFloat (); else if (sy == STR) value = GetString (); else if (sy == CHR) value = GetChar (); else Error ("Value expected"); // inp.h CheckSymbol (SEMICOLON); PutStd (name + " is " + value); PutEol (); } Unindent (); CheckSymbol (RBRACE); PutStd ("end of " + type); PutEol (); } void example () { while (sy!=EOS) { object (); } }