From f1642931e0f1d0c3466c32871bb34f94ee4dc44d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 2 Jan 2020 16:00:56 +0000 Subject: [PATCH] Lexer: Allow "-" char in the middle of identifier names. This allows eg maintainer-clean to be a goal name. --- TODO | 2 -- src/cmdline.ml | 2 +- src/lexer.mll | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 379bb14..3dfec23 100644 --- a/TODO +++ b/TODO @@ -8,5 +8,3 @@ might allow goals to be called with labelled parameters. Functions, eg. wildcard("*.c"). These should be defined as shell scripts with a selection of common functions defined in stdlib. - -Allow "-" character in identifiers, so eg. "goal maintainer-clean" works. diff --git a/src/cmdline.ml b/src/cmdline.ml index cc20d76..b155298 100644 --- a/src/cmdline.ml +++ b/src/cmdline.ml @@ -23,7 +23,7 @@ open Utils (* See also "let id" in [lexer.mll]. *) let var_regexp = - Str.regexp "\\([a-zA-Z_][a-zA-Z0-9_]*\\)[ \t]*=[ \t]*\\(.*\\)" + Str.regexp "\\([a-zA-Z_][-a-zA-Z0-9_]*\\)[ \t]*=[ \t]*\\(.*\\)" let usage = "\ diff --git a/src/lexer.mll b/src/lexer.mll index 84f2af2..fa73312 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -34,7 +34,7 @@ let new_line lexbuf = let white = [' ' '\t']+ let newline = '\r' | '\n' | "\r\n" let comment = '#' (_#'\n')* -let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']* +let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_' '-']* rule read = parse -- 1.8.3.1