You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, scanner.Token is a struct with four fields, line number, column, type, and value. Especially with the new macro system, this is not an ideal structure for a number of reasons:
In at least one place, token information is passed around for just the type and value, and then the other fields are filled in later. This is awkward because it means that the user can set fields with data that is just simply ignored, but seems like it wouldn't necessarily be.
Separating type and value info is mostly pointless. That information can be handled by the Go type system instead, which would also prevent invalid types and, more importantly, invalid type and value combinations.
Instead of this, I think it makes sense to replace the current Token type with one something like the following:
The various token types can then be implemented as concrete types that represent their actual values. This means as well that the Macro token type can be changed more simply from a [2]string to a struct { Name string; Input string }, and macros themselves can return []TokenValues instead of []Tokens.
The text was updated successfully, but these errors were encountered:
Currently,
scanner.Token
is a struct with four fields, line number, column, type, and value. Especially with the new macro system, this is not an ideal structure for a number of reasons:Instead of this, I think it makes sense to replace the current
Token
type with one something like the following:The various token types can then be implemented as concrete types that represent their actual values. This means as well that the
Macro
token type can be changed more simply from a[2]string
to astruct { Name string; Input string }
, and macros themselves can return[]TokenValue
s instead of[]Token
s.The text was updated successfully, but these errors were encountered: