The plan is to modify the translator routines to throw error exceptions when an error is detected. Errors consist of a status, column and length. For translator errors, the column and length will always be obtained from a token, so it made sense to add a constructor that takes status and token pointer arguments.
The Error structure was a plain structure with no constructors, so a default constructor is generated by the compiler taking arguments for the three member variables. Once a constructor is added, this default constructor is no longer generated, so one was added. The constructor taking status and token pointer arguments was also added. Since the structure now has constructors, the member variables were renamed with the member "m_" prefix.
The Error structure was defined in the main header file. This header file does not have access to the token header so that the new constructor can retrieve the column and length from the token, and an include couldn't be added for the token header because the token header already includes this main header file. The Error structure was therefore moved to the token header file. The name Error was a little generic so this structure was renamed to the more appropriate Token Error.
[branch misc-cpp-stl commit 97ce3592c3]
Sunday, November 16, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)