From: Anton Staaf <robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: [PATCH 1/2] Add character literal parsing in bytestrings
Date: Thu, 23 Jun 2011 16:20:38 -0700 [thread overview]
Message-ID: <1308871239-32683-2-git-send-email-robotboy@chromium.org> (raw)
In-Reply-To: <1308871239-32683-1-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
This adds support for parsing simple (non-escaped) 'x' character
literal syntax in bytestrings. For example:
property = ['a' 2b 'c'];
is equivalent to:
property = [61 2b 62];
Signed-off-by: Anton Staaf <robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>
---
Documentation/dts-format.txt | 5 +++--
Documentation/manual.txt | 3 ++-
dtc-lexer.l | 8 ++++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Documentation/dts-format.txt b/Documentation/dts-format.txt
index a655b87..d191eeb 100644
--- a/Documentation/dts-format.txt
+++ b/Documentation/dts-format.txt
@@ -48,11 +48,12 @@ NUL-terminated strings, as bytestrings or a combination of these.
e.g. compatible = "simple-bus";
* A bytestring is enclosed in square brackets [] with each byte
- represented by two hexadecimal digits. Spaces between each byte are
- optional.
+ represented by two hexadecimal digits or a character literal.
+ Spaces between each byte or character literal are optional.
e.g. local-mac-address = [00 00 12 34 56 78]; or equivalently
local-mac-address = [000012345678];
+ e.g. keymap = ['a' 'b' 'c' 'd'];
* Values may have several comma-separated components, which are
concatenated together.
diff --git a/Documentation/manual.txt b/Documentation/manual.txt
index f8a8a7b..f38a995 100644
--- a/Documentation/manual.txt
+++ b/Documentation/manual.txt
@@ -213,7 +213,8 @@ For example:
By default, all numeric values are hexadecimal. Alternate bases
may be specified using a prefix "d#" for decimal, "b#" for binary,
-and "o#" for octal.
+and "o#" for octal. Character literals are supported in
+byte sequences using the C language character literal syntax of 'a'.
Strings support common escape sequences from C: "\n", "\t", "\r",
"\(octal value)", "\x(hex value)".
diff --git a/dtc-lexer.l b/dtc-lexer.l
index e866ea5..1276c6f 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -29,6 +29,7 @@ PROPNODECHAR [a-zA-Z0-9,._+*#?@-]
PATHCHAR ({PROPNODECHAR}|[/])
LABEL [a-zA-Z_][a-zA-Z0-9_]*
STRING \"([^\\"]|\\.)*\"
+CHAR_LITERAL '[^\\']'
WS [[:space:]]
COMMENT "/*"([^*]|\*+[^*/])*\*+"/"
LINECOMMENT "//".*\n
@@ -128,6 +129,13 @@ static int pop_input_file(void);
return DT_BYTE;
}
+<BYTESTRING>{CHAR_LITERAL} {
+ DPRINT("Character literal: %s\n", yytext);
+ yylval.byte = yytext[1];
+ DPRINT("Byte: %02x\n", (int)yylval.byte);
+ return DT_BYTE;
+ }
+
<BYTESTRING>"]" {
DPRINT("/BYTESTRING\n");
BEGIN_DEFAULT();
--
1.7.3.1
next prev parent reply other threads:[~2011-06-23 23:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-23 23:20 [PATCH 0/2] Character literal parsing Anton Staaf
[not found] ` <1308871239-32683-1-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-06-23 23:20 ` Anton Staaf [this message]
[not found] ` <1308871239-32683-2-git-send-email-robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-20 13:40 ` [PATCH 1/2] Add character literal parsing in bytestrings David Gibson
[not found] ` <20110720134006.GJ6399-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-20 16:50 ` Anton Staaf
[not found] ` <CAF6FioX-yYwd3FN106yCwJQD7N27J9XSiUseFHuhTWJGeq3pvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-07-21 5:19 ` David Gibson
[not found] ` <20110721051903.GO6399-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-21 12:41 ` Jon Loeliger
[not found] ` <E1QjsZh-00024e-HY-CYoMK+44s/E@public.gmane.org>
2011-07-27 1:49 ` David Gibson
2011-06-23 23:20 ` [PATCH 2/2] Add escaped character support to character literals Anton Staaf
2011-06-24 20:02 ` [PATCH 0/2] Character literal parsing David Brown
[not found] ` <8yawrgb3smr.fsf-AOX6H5vLt3Uj8izMo0bVsAC/G2K4zDHf@public.gmane.org>
2011-06-24 20:22 ` Anton Staaf
[not found] ` <BANLkTi=iUqMwag-A6t1ubDgSAN9xqWuTMwLG32EKKWuwVbigyg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-24 21:11 ` David Brown
[not found] ` <8yafwmz3pg3.fsf-AOX6H5vLt3Uj8izMo0bVsAC/G2K4zDHf@public.gmane.org>
2011-06-24 21:17 ` Jon Loeliger
[not found] ` <E1QaDkb-0004cc-Jx-CYoMK+44s/E@public.gmane.org>
2011-06-24 21:28 ` Anton Staaf
2011-06-24 21:32 ` Anton Staaf
2011-06-24 21:34 ` Grant Likely
[not found] ` <BANLkTinDPNfXWUOWPR3HmZatE=ohzO0Ybg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-24 21:47 ` Anton Staaf
[not found] ` <BANLkTi=EEuuYSZdLeE1UFsdT=xuEZREkEs+R_FcdQo6JPA-fEQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-28 23:00 ` Anton Staaf
2011-07-20 13:44 ` David Gibson
2011-07-20 13:42 ` David Gibson
[not found] ` <20110720134238.GK6399-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-20 16:23 ` Anton Staaf
[not found] ` <CAF6FioVMOxF7Vc74F6-yPGkwx7xS_xEa03Q2BpQewGaG=ZvkYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-07-20 17:27 ` Jon Loeliger
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=1308871239-32683-2-git-send-email-robotboy@chromium.org \
--to=robotboy-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).