From: "George Spelvin" <linux@horizon.com>
To: ajohnson@redneon.com
Cc: git@vger.kernel.org, linux@horizon.com
Subject: Re: [PATCH v2] userdiff: update Ada patterns
Date: 3 Feb 2014 13:33:01 -0500 [thread overview]
Message-ID: <20140203183301.3642.qmail@science.horizon.com> (raw)
Looking at the grammar at http://www.adahome.com/rm95/rm9x-P.html
and http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-4.html
I see the following restrictions apply:
- A number must begin and end with a digit. There must be at least one
digit on either side of each underscore and decimal point.
- There may be at most one decimal point in a number.
- The base must be between 2 and 16, inclusive.
[-+]?(
[0-9](_?[0-9])*([.][0-9](_?[0-9])*)?|
([2-9]|1[0-6])#[0-9a-fA-F](_?[0-9a-fA-F])*([.][0-9a-fA-F](_?[0-9a-fA-F])*)?#
)([eE][+-]?[0-9](_?[0-9])*)?
If you want a slightly smaller version, we can drop the "only one decimal
point" rule and get
[-+]?(
[0-9]([._]?[0-9])*|
([2-9]|1[0-6])#[0-9a-fA-F]([._]?[0-9a-fA-F])*#
)([eE][+-]?[0-9](_?[0-9])*)?
Ideally, for a based number, the range of acceptable digits would
depend on the base. Which is possible for a finite-state machine since
the number of bases is finite, but laeds to a bit of a state explosion.
Here's an approximation that separates bases 2-9 and 10-16:
[-+]?(
[0-9](_?[0-9])*([.][0-9](_?[0-9])*)?|
[2-9]#[0-8](_?[0-8])*([.][0-8](_?[0-8])*)?#|
1[0-6]#[0-9a-fA-F](_?[0-9a-fA-F])*([.][0-9a-fA-F](_?[0-9a-fA-F])*)?#
)([eE][+-]?[0-9](_?[0-9])*)?
because I think that this is overdoing it:
[-+]?(
[0-9](_?[0-9])*([.][0-9](_?[0-9])*)?|
2#[0-1](_?[0-1])*([.][0-1](_?[0-1])*)?#|
3#[0-2](_?[0-2])*([.][0-2](_?[0-2])*)?#|
4#[0-3](_?[0-3])*([.][0-3](_?[0-3])*)?#|
5#[0-4](_?[0-4])*([.][0-4](_?[0-4])*)?#|
6#[0-5](_?[0-5])*([.][0-5](_?[0-5])*)?#|
7#[0-5](_?[0-5])*([.][0-5](_?[0-5])*)?#|
8#[0-7](_?[0-7])*([.][0-7](_?[0-7])*)?#|
9#[0-8](_?[0-8])*([.][0-8](_?[0-8])*)?#|
10#[0-9](_?[0-9])*([.][0-9](_?[0-9])*)?#|
11#[0-9aA](_?[0-9aA])*([.][0-9aA](_?[0-9aA])*)?#|
12#[0-9abAB](_?[0-9abAB])*([.][0-9abAB](_?[0-9abAB])*)?#|
13#[0-9a-cA-C](_?[0-9a-cA-C])*([.][0-9a-cA-C](_?[0-9a-cA-C])*)?#|
14#[0-9a-dA-D](_?[0-9a-dA-D])*([.][0-9a-dA-D](_?[0-9a-dA-D])*)?#|
15#[0-9a-eA-E](_?[0-9a-eA-E])*([.][0-9a-eA-E](_?[0-9a-eA-E])*)?#|
16#[0-9a-fA-F](_?[0-9a-fA-F])*([.][0-9a-fA-F](_?[0-9a-fA-F])*)?#|
)([eE][+-]?[0-9](_?[0-9])*)?
Another point is that Ada doesn't actually include leading + or -
signs in the syntax for "number", but rather makes them unary operators.
This means that spaces are allowed, and whether you want to include them
in the "number" pattern is a judgement call.
next reply other threads:[~2014-02-03 18:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 18:33 George Spelvin [this message]
2014-02-03 20:05 ` [PATCH v2] userdiff: update Ada patterns Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2014-02-02 10:51 [PATCH] " Adrian Johnson
2014-02-02 23:35 ` Jeff King
2014-02-03 11:33 ` [PATCH v2] " Adrian Johnson
2014-02-03 20:00 ` Junio C Hamano
2014-02-05 10:44 ` Adrian Johnson
2014-02-05 17:17 ` Junio C Hamano
2014-02-05 17:28 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140203183301.3642.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=ajohnson@redneon.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.