From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, test/, bashast/gunit/
Date: Sat, 9 Apr 2011 13:08:58 +0000 (UTC) [thread overview]
Message-ID: <842c390d16c128f5271f193b26bd35a0a5c97ef2.betelgeuse@gentoo> (raw)
commit: 842c390d16c128f5271f193b26bd35a0a5c97ef2
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 8 13:53:15 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr 9 13:02:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=842c390d
Transform ESC_CHAR token into a parser rule
ESC_CHAR results in huge lexer file size. After the transformation,
the size of lexer is reduced by 1/3.
---
bashast/bashast.g | 16 +++++++++-------
bashast/gunit/fname.gunit | 10 +++++-----
test/post_check.cpp | 2 +-
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 6230b66..356142a 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -363,10 +363,11 @@ ns_str_part
ns_str_part_no_res
: num
| name
+ | esc_char
|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|TEST_EXPR|'_'
|TILDE|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN
|TIME_POSIX|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN
- |OR_ASSIGN|ESC_CHAR|CARET;
+ |OR_ASSIGN|CARET;
//strings with no slashes, used in certain variable expansions
ns_str : ns_str_part* -> ^(STRING ns_str_part*);
//Generic strings/filenames.
@@ -493,6 +494,7 @@ parens : LPAREN BLANK* RPAREN;
name : NAME
| LETTER
| '_';
+esc_char: ESC (DIGIT DIGIT? DIGIT?|LETTER ALPHANUM ALPHANUM?|.);
//****************
// TOKENS/LEXER RULES
@@ -602,17 +604,17 @@ LOGICOR : '||';
EXPORT : 'export';
//Tokens for strings
CONTINUE_LINE
- : ('\\' EOL)+{$channel=HIDDEN;};
+ : (ESC EOL)+{$channel=HIDDEN;};
ESC_RPAREN
- : '\\' RPAREN;
+ : ESC RPAREN;
ESC_LPAREN
- : '\\' LPAREN;
-ESC_LT : '\\''<';
-ESC_GT : '\\''>';
+ : ESC LPAREN;
+ESC_LT : ESC'<';
+ESC_GT : ESC'>';
//For pipeline
TIME_POSIX
: '-p';
//Handle ANSI C escaped characters: escaped octal, escaped hex, escaped ctrl+ chars, then all others
-ESC_CHAR: '\\' (('0'..'7')('0'..'7')('0'..'7')?|'x'('0'..'9'|'a'..'f'|'A'..'F')('0'..'9'|'a'..'f'|'A'..'F')?|'c'.|.);
+ESC : '\\';
NAME : (LETTER|'_')(ALPHANUM|'_')+;
OTHER : .;
diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit
index 0272c37..e783504 100644
--- a/bashast/gunit/fname.gunit
+++ b/bashast/gunit/fname.gunit
@@ -42,11 +42,11 @@ fname:
"ab@(gh|i)" -> (STRING ab (MATCH_EXACTLY_ONE (STRING gh) (STRING i)))
"ab!(gh|i)" -> (STRING ab (MATCH_NONE (STRING gh) (STRING i)))
"\"abc\"\'\"\'\"def\"" -> (STRING (DOUBLE_QUOTED_STRING abc) (SINGLE_QUOTED_STRING ") (DOUBLE_QUOTED_STRING def))
-"my\ name\ is" -> (STRING my \ name \ is)
-"octal\007" -> (STRING octal \007)
-"hex\xaF" -> (STRING hex \xaF)
-"ctrlx\cx" -> (STRING ctrlx \cx)
-"tab\\ttab" -> "(STRING tab \\\t tab)"
+"my\ name\ is" -> (STRING my \ name \ is)
+"octal\007" -> (STRING octal \ 007)
+"hex\xaF" -> (STRING hex \ xaF)
+"ctrlx\cx" -> (STRING ctrlx \ cx)
+"tab\\ttab" -> "(STRING tab \\ \t tab)"
"abc[def]" -> (STRING abc (MATCH_PATTERN def))
"a[]" -> (STRING a [ ])
"ab[d-h]" -> (STRING ab (MATCH_PATTERN d - h))
diff --git a/test/post_check.cpp b/test/post_check.cpp
index 1385290..ebe0409 100644
--- a/test/post_check.cpp
+++ b/test/post_check.cpp
@@ -36,7 +36,7 @@ static void check_file_size(const char *path, uintmax_t size_max)
TEST(post_check, lexer_size)
{
- check_file_size("libbashLexer.c", 1024 * 1024);
+ check_file_size("libbashLexer.c", 512 * 1024);
}
TEST(post_check, parser_size)
next reply other threads:[~2011-04-09 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 13:08 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-04-11 6:50 [gentoo-commits] proj/libbash:master commit in: bashast/, test/, bashast/gunit/ Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-06-16 16:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
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=842c390d16c128f5271f193b26bd35a0a5c97ef2.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.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