From patchwork Mon Feb 4 15:27:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 2093231 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id AFEAB3FC23 for ; Mon, 4 Feb 2013 15:56:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E8CFE61A5 for ; Mon, 4 Feb 2013 07:56:59 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 72513E60BF for ; Mon, 4 Feb 2013 07:29:51 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 04 Feb 2013 07:29:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,600,1355126400"; d="scan'208";a="257442114" Received: from unknown (HELO dyon.amr.corp.intel.com) ([10.255.12.132]) by orsmga001.jf.intel.com with ESMTP; 04 Feb 2013 07:29:50 -0800 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Mon, 4 Feb 2013 15:27:52 +0000 Message-Id: <1359991705-5254-58-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.7.7.5 In-Reply-To: <1359991705-5254-1-git-send-email-damien.lespiau@intel.com> References: <1359991705-5254-1-git-send-email-damien.lespiau@intel.com> Subject: [Intel-gfx] [PATCH 57/90] assembler: Add location support X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Let's generate location information about the tokens we are parsing. This can be used to give accurate location when reporting errors and warnings. Signed-off-by: Damien Lespiau --- assembler/gram.y | 1 + assembler/lex.l | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/assembler/gram.y b/assembler/gram.y index 8b56bd9..9a4e510 100644 --- a/assembler/gram.y +++ b/assembler/gram.y @@ -276,6 +276,7 @@ static void resolve_subnr(struct brw_reg *reg) %} +%locations %start ROOT diff --git a/assembler/lex.l b/assembler/lex.l index 626042f..769d98b 100644 --- a/assembler/lex.l +++ b/assembler/lex.l @@ -9,6 +9,15 @@ int saved_state = 0; extern char *input_filename; +/* Locations */ +int yycolumn = 1; + +#define YY_USER_ACTION \ + yylloc.first_line = yylloc.last_line = yylineno; \ + yylloc.first_column = yycolumn; \ + yylloc.last_column = yycolumn+yyleng-1; \ + yycolumn += yyleng; + %} %x BLOCK_COMMENT %x CHANNEL @@ -16,11 +25,11 @@ extern char *input_filename; %x FILENAME %% -\/\/.*[\r\n] { } /* eat up single-line comments */ -"\.kernel".*[\r\n] { } -"\.end_kernel".*[\r\n] { } -"\.code".*[\r\n] { } -"\.end_code".*[\r\n] { } +\/\/.*[\r\n] { yycolumn = 1; } /* eat up single-line comments */ +"\.kernel".*[\r\n] { yycolumn = 1; } +"\.end_kernel".*[\r\n] { yycolumn = 1; } +"\.code".*[\r\n] { yycolumn = 1; } +"\.end_code".*[\r\n] { yycolumn = 1; } /* eat up multi-line comments, non-nesting. */ \/\* { @@ -33,6 +42,7 @@ extern char *input_filename; . { } [\r\n] { } "#line"" "* { + yycolumn = 1; saved_state = YYSTATE; BEGIN(LINENUMBER); } @@ -407,7 +417,9 @@ yylval.integer = BRW_CHANNEL_W; return NUMBER; } -[ \t\n]+ { } /* eat up whitespace */ +[ \t]+ { } /* eat up whitespace */ + +\n { yycolumn = 1; } . { fprintf(stderr, "%s: %d: %s at \"%s\"\n",