-1

I am already using yylineno in my Flex, Bison, and C project. However, I would also like to use a column number to pinpoint the exact location of a lexical error on a particular line. Does Flex have no implementation of a column number? The only reason I can of is because the tab character '\t' can be set to accept to any number of spaces. If there is already an implementation I would like to use instead of reinventing the wheel.

I have searched through the book "Lexical Analysis with Flex", Edition 2.6.0, 10 November 2015 by Vern Paxson, Will Estes and John Millaway. I also searched Google but no luck. I hope someone can help. Thanks

Nick
  • 9
  • 1
  • Did you just ask this exact same question with almost exactly the same text, referencing the exactly same book? Don't do that! Improve the first question you have instead. – Some programmer dude May 30 '23 at 19:28
  • I deleted that question because I couldn't remove the tag "flexbox". I actually typed in "flex" but instead it added flexbox (don't know how). It was too late. I had already posted that question. I couldn't how to delete that tag. So, I just deleted the question and started over. – Nick May 30 '23 at 19:39
  • 1
    There's an `Edit` link right below the tags. That allows you to edit your whole question, including the tags. – Some programmer dude May 30 '23 at 19:45

1 Answers1

0

Does Flex (lexical analysis) have no implementation of a column number?

Flex does not track a position on the current line for you.

However, you might be interested in Flex's bison-locations option, which works together with Bison's locations feature.

Note that Flex does provide yylen, the length of the current token, and it recognizes YY_USER_ACTION, which you can use to insert code before every action. Between these, it is relatively easy to track the position on the line manually.

You can find more information in How does flex support bison-location exactly?

John Bollinger
  • 160,171
  • 8
  • 81
  • 157