Skip to content

[Unsure/Bug]: (VSCode) Some issues with scope handling... #683

@its-19818942118

Description

@its-19818942118

I am using clangd. now normally it works super well with clangd and compile commands enabled... but other than that? from what I have seen. it just doesn't play nice...

The code with a problem is:

std::vector
  <Token>
    tokenize
    ( const std::string& str )
{
    
    std::vector <Token> tokens;
    
    std::string buf;
    for (int i = 0; i< str.length(); i++){
      char c = str.at(i);
      if (isalpha(c)) {
        buf.push_back(c);
        i++;

        while (std::isalnum(str.at(i))) {
          buf.push_back(str.at(i));
          i++;
        }
        i--; // fixes the one char ahead thing. REFACTOR later.
        if(buf == "return"){
            tokens.push_back({.type = TokenType::jreturn});
            buf.clear(); //clear buffer after a word has been detected and tokenised.
            continue;
        } else{
            std::cerr<<"ya messed up"<<std::endl;
            exit(EXIT_FAILURE);
        }
        }
        else if(std::isdigit(c)){
            buf.push_back(c);
            i++;
            while(std::isdigit(str.at(i))){
                buf.push_back(str.at(i));
                i++;
            }
            i--;
            tokens.push_back({.type = TokenType::int_lit, .value = buf});
            buf.clear();
        }
        else if(c == ';'){
            tokens.push_back({.type = TokenType::jemi});
        }
        else if(std::isspace(c)){
            continue;
        }
        else{
            std::cerr<<"YA MESSED UP"<<std::endl;
            exit(EXIT_FAILURE);
        }

    }

    // 3rd approah: if i see a letter, i'll start readig it into a buffer until its no loger a letter or no,
    // that'll maybe help find out what the buffer contains and it its a token.

    // todo : fix segfault (add ret whe i have cotent worth returing)
    return tokens;
}

// THIS isn't my code. I am using this to test out my theme.

It looks like:

** My Custom Theme: C/C++ Spirit Dark **

Image

It should look like:

** should be very very vibrant and catchy **

Image

With this mess of a cursed formatting 😔. it works fine. but change the formatting a little. move names to a new line??? and its all over... Please help me out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions