Stephen Murby
Stephen Murby

Reputation: 1467

Operators in Lexical Analysis

I am revising some things on the compiler for an uni exam, and I wondered what ID an operator token had? For example...

float position, initial, rate;
position = initial += rate * 60

Token, Type; position, ID; =, =; initial, ID; +=, ??? (What type is this); rate, ID; *, *; 60, num;

Upvotes: 0

Views: 273

Answers (1)

mikemxm
mikemxm

Reputation: 472

Are you sure that += isn't +=? I think it should be a standard defined operator just like + or =.

This MSDN article says that the compiler should choose the longest token possible (reading left-to-right), so your compiler shouldn't confuse i+=5 as two operators. The example they give is i+++j == (i++) + j.

Upvotes: 1

Related Questions