//
LocationsBag lbag;
List<Tuple<Modifiers, Location>> mod_locations;
+ Stack<Location> location_stack;
%}
%token EOF
attribute_section
: OPEN_BRACKET
{
+ PushLocation (GetLocation ($1));
lexer.parsing_attribute_section = true;
}
attribute_section_cont
else
$$ = $4;
+ if ($5 != null) {
+ lbag.AddLocation ($$, PopLocation (), GetLocation ($2), GetLocation ($5), GetLocation ($6));
+ } else {
+ lbag.AddLocation ($$, PopLocation (), GetLocation ($2), GetLocation ($6));
+ }
+
current_attr_target = null;
lexer.parsing_attribute_section = false;
}
| attribute_list opt_comma CLOSE_BRACKET
{
$$ = $1;
+
+ if ($2 != null) {
+ lbag.AddLocation ($$, PopLocation (), GetLocation($2), GetLocation ($3));
+ } else {
+ lbag.AddLocation ($$, PopLocation (), GetLocation($3));
+ }
}
| IDENTIFIER error
{
{
$$ = current_variable;
current_variable = null;
- lbag.AddLocation ($$, GetLocation ($6));
+ if ($4 != null)
+ lbag.AddLocation ($$, PopLocation (), GetLocation ($6));
+ else
+ lbag.AddLocation ($$, GetLocation ($6));
}
| CONST variable_type identifier_inside_body
{
| ASSIGN block_variable_initializer
{
current_variable.Initializer = (Expression) $2;
- // TODO: lbag
+ PushLocation (GetLocation ($1));
+ $$ = current_variable;
}
| error
{
mod_locations.Add (Tuple.Create ((Modifiers) token, loc));
}
+[System.Diagnostics.Conditional ("FULL_AST")]
+void PushLocation (Location loc)
+{
+ if (location_stack == null)
+ location_stack = new Stack<Location> ();
+
+ location_stack.Push (loc);
+}
+
+Location PopLocation ()
+{
+ if (location_stack == null)
+ return Location.Null;
+
+ return location_stack.Pop ();
+}
+
string CheckAttributeTarget (string a, Location l)
{
switch (a) {