enums - C++ calling a method from another class -


  • I have 2 squares with their header files, which are lexer.cpp and lexer.h, token.cpp And tokens are called .h
  • It is necessary to make them the compiler. I'm still lexmeas currently, dividing and reading tokens.
  • Now I have a method that will load each character from the file, and for example it shows that this is an integer, it will return a token (which is token.cpp in the token)

    Problem:

    .cpp in tokk I have an enum class token that contains all tokens which can be read by my compiler (Coding will be given below)

    Now

    1. Lexer.cpp is to call this class (Enum class token in Token.cpp ) token.h I have just declared the name of the class
    2. Lexer.h wrote the name of the method which should be used in Lexer.cpp

      But they are creating some errors.


      Error: error


      Code:

      Lexer.cpp

        Token Lexer :: MillTextToken (four CH ) {Return Token :: Vacuum; }   

      lexer.h

        #ifndef lexer #define lexer #include "token.h" square laser {public: Four readrets (); Bool istagit (four f); Bull Isafa (four f); Bull eye ordination (four f); Token Mill Token (four f); }; #endif // lexer.h   

      Token H

        #ifndef token #define token enum class token {tkLetter, tkDigit , tkPrintable, tkType, // Literals tkBooleanLiteral, tkIntegerLiteral, tkRealLiteral, tkCharLiteral, tkStringLiteral, tkUnitLiteral, tkLiteral, tkIndentifier, // operation tkMultpicativeOp, tkAdditiveOp, tkRelationalOp, // parameter and call tkActualParams, tkFunctionCall, // cast and factors tkTypeCast, TkSubExpression , tkUnary, tkFactor, // terms and announcements tkTerm, tkSimpleExpression, tkExpression, tkAssignment, tkVariableDecl, tkFormalParam, tkFunctionDecl, // statement tkReadStatement, tkWriteStatement, tkIfStatement, tkWhileStatement, tkHaltStatement, tkStatement, tkBlock, tkSxl,};  transfer the definition of enum class token  

      token.h Replace with the same name with the same name and Lexer

      > token.cpp h

      As I said in token declaration from CPP to Tokens.H. Is it clear to run in?

      and the function should appear as getNextToken

        token lexer :: getNextToken (char ch) {return token :: tkDigit; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -