From patchwork Tue Jun 2 23:58:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187399 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp28018ilo; Tue, 2 Jun 2020 17:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+OoU9MitUB5PE8zQqrwbJCtBpa9fTrh7xKu81V1+Jv6GIk3XLwqVb81WpxMnDmuMVvd0Z X-Received: by 2002:a25:6d88:: with SMTP id i130mr45426103ybc.306.1591142559721; Tue, 02 Jun 2020 17:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591142559; cv=none; d=google.com; s=arc-20160816; b=pkX6Ee2olc5851yhfypUoktaIKnIcC3RvLzaCv9HfWsdI37nROsZTw+3VdgzMA9pRu h/mBzyVyHe8aLoy7jIOcHqH4wOTyDyX9R6H0etmn0jT4SLqjf7lJ2p/3055QY71aKt66 PYXEUFUnWsyb6XRBCMutNnGUWuqAPlYk4yb4t/CkbeSM7Tl3VBYbZyI30fpLBDBlbkyT X47DgVjWgcrhBj84mZfkJ9P7mAFEVh5IRcZRgWxs07KF///oYmW/dVj/SyEWViUuPhil AWlgAyxPe5g5YH2js9vbvvMI4y67aVE0v/XNDClKi4s2Q1l8EqFqgu42smCD7JpoT/u4 ZBYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=T9g/1bYL5AF8SWtZFiFU5ixPPASa6ChAdx/2pCnn8+k=; b=xP09PjIwjZcmd8Rl1H/uShjXHw4o8qu5Wf1E10V+RTc0JY8V3OYAeDcnyn5sNUXhtP w2uFW+AixUuM3b2xRWLvhaLhLTcd2wV2vw8Btk6n/mhjHI6jCRXG/HjCTgGEsPjB6ngV nF+XmbkFdyhZ6gToK/1PxLn3yG5E+LjQS4rWc+ggIkKe6/3MON8ObOG10qH0Jzz/Kny/ N873h4vBUX4Iql1qgj7vrI71esGT1P6LeWCn16MHLzpeHksTJZQxHw0VnBpA6x3KxAHt MYk1n3QjaunfYMfUlhQlrebK4tjoAJWgnvV0Qk4T/c0lsesmvGFqio96B4yJSB334yEb JFjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qZJBNhgo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x14si180098ybf.89.2020.06.02.17.02.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 17:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qZJBNhgo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgGrf-0002MB-8J for patch@linaro.org; Tue, 02 Jun 2020 20:02:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgGnv-0004uM-9z for qemu-devel@nongnu.org; Tue, 02 Jun 2020 19:58:47 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:40715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgGnu-00024y-FV for qemu-devel@nongnu.org; Tue, 02 Jun 2020 19:58:47 -0400 Received: by mail-pf1-x429.google.com with SMTP id v2so294117pfv.7 for ; Tue, 02 Jun 2020 16:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T9g/1bYL5AF8SWtZFiFU5ixPPASa6ChAdx/2pCnn8+k=; b=qZJBNhgobPOrNgGlxq5XE+HbFruffBAbh+WUkUA+QIHdbWHFD4FGbbeRb4SUax5YzT rYwh6A95BJlleTrEpkr9E1jsV+fJZgHZwPCkW79IumzvMO2bHvBTaf0CQFGeSjnYTJ1q BpzjLNtZTNq5JICPOZpQx9tExo4JdNm+oOjQFILoM1RJ6SwZU6DpPQmq6MoAyoBVky+/ 7rba46wOzG3rt0ImrQQs6YGEgvRMncdd+0cEQvrDtEf/QV2uCU8i4r+YxHfANmYbKNl6 dWNBKx3muSfLRlcpCa1CQe5hB5hZIUq4aFMiLt8vbLCOrnyFqWxEaMz47/lDjn6Oo6v9 2InQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T9g/1bYL5AF8SWtZFiFU5ixPPASa6ChAdx/2pCnn8+k=; b=j85uPZB35zFIDxEgCy9k0zQaQj6742B7OpsJwCjOYs/1D2sJ9cX9xCRlzh8+awssiG kX5u3xaVyOAvGv5npkmpXkJCHU/nuORKwE/d/yBBUgB8hHj04CcJ4iiAtXEE4fSyA/43 S/nv/l59RtrpLXsW7aty8Cdnya0Gxbv39Ytyz8a7gDPJdwcDhKN2rLiQGO/OazGRXIun PCpkpvd+2XOip4ovsqRTuLYyCwbVxBXlDntTPNFm4N/ZUB7U7dp4qnlBVfPBZTD5sXjU L3a/duPfWMS/WkUncAoK+xEEx+fPeRq38OIWxvCLFgFWz9caEhT0e9o77HzMgnZkMe+g e0GQ== X-Gm-Message-State: AOAM533Cn0jzfaP66uPuS2uKxTKcLaOTf553PR6vJiQQ62U8o29IZqo9 Es+yyJtkpivf9qNIsDSpbbPefbdQwzo= X-Received: by 2002:aa7:93ac:: with SMTP id x12mr29950554pff.143.1591142324732; Tue, 02 Jun 2020 16:58:44 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id k101sm182201pjb.26.2020.06.02.16.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 16:58:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] decodetree: Implement non-overlapping groups Date: Tue, 2 Jun 2020 16:58:32 -0700 Message-Id: <20200602235834.470345-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602235834.470345-1-richard.henderson@linaro.org> References: <20200602235834.470345-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, philmd@redhat.com, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Intended to be nested within overlapping groups. Reviewed-by: Philippe Mathieu-Daudé Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- scripts/decodetree.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 0ba01e049c..7e3b1d1399 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1021,16 +1021,20 @@ def parse_file(f, parent_pat): del toks[0] # End nesting? - if name == '}': + if name == '}' or name == ']': if len(toks) != 0: error(start_lineno, 'extra tokens after close brace') if len(parent_pat.pats) < 2: error(lineno, 'less than two patterns within braces') + # Make sure { } and [ ] nest properly. + if (name == '}') != isinstance(parent_pat, IncMultiPattern): + error(lineno, 'mismatched close brace') + try: parent_pat = nesting_pats.pop() except: - error(lineno, 'mismatched close brace') + error(lineno, 'extra close brace') nesting -= 2 if indent != nesting: @@ -1044,11 +1048,14 @@ def parse_file(f, parent_pat): error(start_lineno, 'indentation ', indent, ' != ', nesting) # Start nesting? - if name == '{': + if name == '{' or name == '[': if len(toks) != 0: error(start_lineno, 'extra tokens after open brace') - nested_pat = IncMultiPattern(start_lineno) + if name == '{': + nested_pat = IncMultiPattern(start_lineno) + else: + nested_pat = ExcMultiPattern(start_lineno) parent_pat.pats.append(nested_pat) nesting_pats.append(parent_pat) parent_pat = nested_pat @@ -1067,6 +1074,9 @@ def parse_file(f, parent_pat): else: parse_generic(start_lineno, parent_pat, name, toks) toks = [] + + if nesting != 0: + error(lineno, 'missing close brace') # end parse_file