8.6.1. Lexical concepts in the state of the parser
The parsers keep current context, current subject and current object in state. This means that any parser can retrieve a representation from state that represents these lexical concepts for the lexical position it starts to work on (if they are defined at all, of course, at that position).
8.6.1.1. Current context
The current context is represented in ArcParserState (module Perspectives.Parsing.Arc.IndentParser) as the member currentcontext
. Every parser can extract the lexical current context from state. For our purposes we need to know that this current context is part of the representation of current subject, current object and current state. The representation is a fully qualified type.
8.6.1.2. Current subject
In the body of the following constructs, a current subject is defined:
-
the body of a perspective of <user>;
-
the body of a user role definition;
-
the block of assignments following do for <user>, defining an action
-
the expression following notify <user>.
In ArcParserState, the current subject is represented by a RoleIdentification:
data RoleIdentification = ExplicitRole ContextType RoleType ArcPosition | ImplicitRole ContextType Step
The ContextType part represents the current context (as stated in the previous paragraph). For ExplicitRole, this means that RoleType is defined in the context of the ContextType. In an ImplicitRole, the Step is the parse tree of an expression. It should be evaluated with respect to its ContextType: we interpret an expression in its current context.
It turns out that in all of the situations above, an ExplicitRole is constructed.
In fact, as shown below, an ImplicitRole is only ever constructed on parsing a perspective on clause.
In all cases except for perspective of <user>, the RoleType part is a fully qualified name (we qualify this case in PhaseThree of the parser, when all role types of the model are available).
ArcParserState holds a member subject that represents the lexical current subject.
A note on calculated roles. The role type in ExplicitRole can be calculated (except when it is the external role) and will then be a CalculatedRoleType.
8.6.1.3. Current object
The current object is in scope in:
-
the block following a perspective on;
-
the body of a non-user role definition.
As with current subject, current object is represented in the parse tree by a RoleIdentification. A role definition results in an ExplicitRole with a fully qualified name, but a perspective on results in an ImplicitRole.
ArcParserState holds a member object that represents the lexical current object.