void Imperative_decoratedIdentifier(out ProtoCore.AST.ImperativeAST.ImperativeNode node) { node = null; if (IsLocallyTypedVariable()) { Expect(1); if (IsKeyWord(t.val, true)) { errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val)); } var typedVar = new ProtoCore.AST.ImperativeAST.TypedIdentifierNode(); typedVar.Name = typedVar.Value = t.val; NodeUtils.SetNodeLocation(typedVar, t); Expect(47); Expect(40); typedVar.IsLocal = true; Expect(1); int type = core.TypeSystem.GetType(t.val); if (type == ProtoCore.DSASM.Constants.kInvalidIndex) { var unknownType = new ProtoCore.Type(); unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex; unknownType.Name = t.val; typedVar.DataType = unknownType; } else { typedVar.DataType = core.TypeSystem.BuildTypeObject(type, 0); } if (la.kind == 10) { var datatype = typedVar.DataType; Get(); Expect(11); datatype.rank = 1; if (la.kind == 10 || la.kind == 24) { if (la.kind == 24) { Get(); Expect(10); Expect(11); datatype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; } else { while (la.kind == 10) { Get(); Expect(11); datatype.rank++; } } } typedVar.DataType = datatype; } node = typedVar; } else if (IsLocalVariable()) { Expect(1); if (IsKeyWord(t.val, true)) { errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val)); } var identNode = new ProtoCore.AST.ImperativeAST.IdentifierNode(); identNode.Name = identNode.Value = t.val; NodeUtils.SetNodeLocation(identNode, t); Expect(47); Expect(40); identNode.IsLocal = true; node = identNode; } else if (IsTypedVariable()) { Expect(1); if (IsKeyWord(t.val, true)) { errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val)); } var typedVar = new ProtoCore.AST.ImperativeAST.TypedIdentifierNode(); typedVar.Name = typedVar.Value = t.val; NodeUtils.SetNodeLocation(typedVar, t); Expect(47); Expect(1); int type = core.TypeSystem.GetType(t.val); if (type == ProtoCore.DSASM.Constants.kInvalidIndex) { var unknownType = new ProtoCore.Type(); unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex; unknownType.Name = t.val; typedVar.DataType = unknownType; } else { typedVar.DataType = core.TypeSystem.BuildTypeObject(type, 0); } if (la.kind == 10) { var datatype = typedVar.DataType; Get(); Expect(11); datatype.rank = 1; if (la.kind == 10 || la.kind == 24) { if (la.kind == 24) { Get(); Expect(10); Expect(11); datatype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; } else { while (la.kind == 10) { Get(); Expect(11); datatype.rank++; } } } typedVar.DataType = datatype; } node = typedVar; } else if (la.kind == 1 || la.kind == 12 || la.kind == 45) { Imperative_IdentifierList(out node); } else SynErr(113); }
void Imperative_decoratedIdentifier(out ProtoCore.AST.ImperativeAST.ImperativeNode node) { node = null; if (IsTypedVariable()) { Expect(1); if (IsKeyWord(t.val, true)) { errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val)); } var typedVar = new ProtoCore.AST.ImperativeAST.TypedIdentifierNode(); typedVar.Name = typedVar.Value = t.val; NodeUtils.SetNodeLocation(typedVar, t); Expect(48); Expect(1); int type = core.TypeSystem.GetType(t.val); if (type == ProtoCore.DSASM.Constants.kInvalidIndex) { var unknownType = new ProtoCore.Type(); unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex; unknownType.Name = t.val; typedVar.datatype = unknownType; } else { typedVar.datatype = core.TypeSystem.BuildTypeObject(type, false); } if (la.kind == 7) { var datatype = typedVar.datatype; Get(); Expect(8); datatype.rank = 1; if (la.kind == 7 || la.kind == 21) { if (la.kind == 21) { Get(); Expect(7); Expect(8); datatype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; } else { while (la.kind == 7) { Get(); Expect(8); datatype.rank++; } } } typedVar.datatype = datatype; } node = typedVar; } else if (la.kind == 1 || la.kind == 9 || la.kind == 44) { Imperative_IdentifierList(out node); } else SynErr(115); }