1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System.Linq; 9 using Antmicro.Renode.Core; 10 using Antmicro.Renode.Exceptions; 11 12 namespace Antmicro.Renode.UserInterface.Tokenizer 13 { 14 public class AbsoluteRangeToken : RangeToken 15 { AbsoluteRangeToken(string value)16 public AbsoluteRangeToken(string value) : base(value) 17 { 18 var trimmed = value.TrimStart('<').TrimEnd('>'); 19 var split = trimmed.Split(',').Select(x => x.Trim()).ToArray(); 20 var resultValues = ParseNumbers(split); 21 22 if(resultValues[0] > resultValues[1]) 23 { 24 // split is used instead of resultValues to print numbers using the same format as input. 25 throw new RecoverableException( 26 "Could not create range; the start address can't be higher than the end address.\n" 27 + $"Use '<{split[0]} {split[1]}>' without a comma if the second argument is size." 28 ); 29 } 30 Value = resultValues[0].To(resultValues[1]); 31 } 32 } 33 } 34