0

I'm trying to learn how to use flex and I'm having some issues:

  • each time when a token is found I want it to be store in a token I created, that part works just fine!
  • the issue begins when it gets to the next token for example, if I've written: "a bcd" , it should identify it as a token a, and then as a token bcd, instead I'm getting the next:

    token a(at the first scan),
    and at the second scan I'm getting 2 tokens:
    token a
    token a bcd.

What am I missing? (When it recognize bcd, it just changes the token a to a bcd for some reason).

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
secret
  • 505
  • 4
  • 16
  • Code is text, please include it as such. Images cannot be copied to editors and cannot be searched. All in all create a [minimal, complete and verifiable example](http://stackoverflow.com/help/mcve). It does not have to be your code verbatim. You can create a separate little example that demonstrates your problem. – Ilja Everilä Apr 12 '17 at 07:00
  • added the code as asked.... – secret Apr 12 '17 at 07:15
  • 1
    On buglet: the printfs have excess args without a format, atoi(yytext). Did you enable all warnings from your compiler? – Jens Apr 12 '17 at 07:21
  • @Jens , that is not the issue, I fixed it and yet problem stays the same... – secret Apr 12 '17 at 07:32

1 Answers1

1

Problem was since yytext update itself, you need to copy it to a new char in order to work

secret
  • 505
  • 4
  • 16