Initial pass at D language expression parser support.
gdb/ 2014-06-05 Iain Buclaw <ibuclaw@gdcproject.org> * Makefile.in (SFILES): Add d-exp.y. (YYFILES): Add d-exp.c. (YYOBJ): Add d-exp.o. (local-maintainer-clean): Delete d-exp.c. * d-exp.y: New file. * d-lang.h (d_parse): New declaration. (d_error): New declaration. * d-lang.c (d_op_print_tab): Add entry for BINOP_CONCAT and BINOP_EXP. Set BINOP_EQUAL and BINOP_NOTEQUAL to same precedence as other PREC_ORDER operators. (d_language_defn): Use d_parse, d_error instead of c_parse, c_error. gdb/testsuite/ 2014-06-05 Iain Buclaw <ibuclaw@gdcproject.org> * gdb.dlang/expression.exp: New file.
This commit is contained in:
parent
78c164b006
commit
3ed9baed43
|
@ -1,3 +1,17 @@
|
|||
2014-06-19 Iain Buclaw <ibuclaw@gdcproject.org>
|
||||
|
||||
* Makefile.in (SFILES): Add d-exp.y.
|
||||
(YYFILES): Add d-exp.c.
|
||||
(YYOBJ): Add d-exp.o.
|
||||
(local-maintainer-clean): Delete d-exp.c.
|
||||
* d-exp.y: New file.
|
||||
* d-lang.h (d_parse): New declaration.
|
||||
(d_error): New declaration.
|
||||
* d-lang.c (d_op_print_tab): Add entry for BINOP_CONCAT and BINOP_EXP.
|
||||
Set BINOP_EQUAL and BINOP_NOTEQUAL to same precedence as other
|
||||
PREC_ORDER operators.
|
||||
(d_language_defn): Use d_parse, d_error instead of c_parse, c_error.
|
||||
|
||||
2014-06-19 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* gdbthread.h (any_running): Remove the declaration.
|
||||
|
|
|
@ -797,7 +797,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
|
|||
charset.c cleanups.c cli-out.c coffread.c coff-pe-read.c \
|
||||
complaints.c completer.c continuations.c corefile.c corelow.c \
|
||||
cp-abi.c cp-support.c cp-namespace.c cp-valprint.c \
|
||||
d-lang.c d-support.c d-valprint.c \
|
||||
d-exp.y d-lang.c d-support.c d-valprint.c \
|
||||
cp-name-parser.y \
|
||||
dbxread.c demangle.c dictionary.c disasm.c doublest.c dummy-frame.c \
|
||||
dwarf2expr.c dwarf2loc.c dwarf2read.c dwarf2-frame.c \
|
||||
|
@ -1052,12 +1052,12 @@ YYFILES = c-exp.c \
|
|||
ada-lex.c \
|
||||
ada-exp.c \
|
||||
jv-exp.c \
|
||||
f-exp.c go-exp.c m2-exp.c p-exp.c
|
||||
d-exp.c f-exp.c go-exp.c m2-exp.c p-exp.c
|
||||
YYOBJ = c-exp.o \
|
||||
cp-name-parser.o \
|
||||
ada-exp.o \
|
||||
jv-exp.o \
|
||||
f-exp.o go-exp.o m2-exp.o p-exp.o
|
||||
d-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o
|
||||
|
||||
# Things which need to be built when making a distribution.
|
||||
|
||||
|
@ -1412,7 +1412,7 @@ local-maintainer-clean:
|
|||
cp-name-parser.c \
|
||||
ada-lex.c ada-exp.c \
|
||||
jv-exp.tab \
|
||||
f-exp.c go-exp.c m2-exp.c p-exp.c
|
||||
d-exp.c f-exp.c go-exp.c m2-exp.c p-exp.c
|
||||
rm -f TAGS $(INFOFILES)
|
||||
rm -f $(YYFILES)
|
||||
rm -f nm.h config.status
|
||||
|
|
File diff suppressed because it is too large
Load Diff
10
gdb/d-lang.c
10
gdb/d-lang.c
|
@ -96,8 +96,8 @@ static const struct op_print d_op_print_tab[] =
|
|||
{"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
|
||||
{"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
|
||||
{"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
|
||||
{"==", BINOP_EQUAL, PREC_EQUAL, 0},
|
||||
{"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
|
||||
{"==", BINOP_EQUAL, PREC_ORDER, 0},
|
||||
{"!=", BINOP_NOTEQUAL, PREC_ORDER, 0},
|
||||
{"<=", BINOP_LEQ, PREC_ORDER, 0},
|
||||
{">=", BINOP_GEQ, PREC_ORDER, 0},
|
||||
{">", BINOP_GTR, PREC_ORDER, 0},
|
||||
|
@ -106,9 +106,11 @@ static const struct op_print d_op_print_tab[] =
|
|||
{"<<", BINOP_LSH, PREC_SHIFT, 0},
|
||||
{"+", BINOP_ADD, PREC_ADD, 0},
|
||||
{"-", BINOP_SUB, PREC_ADD, 0},
|
||||
{"~", BINOP_CONCAT, PREC_ADD, 0},
|
||||
{"*", BINOP_MUL, PREC_MUL, 0},
|
||||
{"/", BINOP_DIV, PREC_MUL, 0},
|
||||
{"%", BINOP_REM, PREC_MUL, 0},
|
||||
{"^^", BINOP_EXP, PREC_REPEAT, 0},
|
||||
{"@", BINOP_REPEAT, PREC_REPEAT, 0},
|
||||
{"-", UNOP_NEG, PREC_PREFIX, 0},
|
||||
{"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
|
||||
|
@ -228,8 +230,8 @@ static const struct language_defn d_language_defn =
|
|||
array_row_major,
|
||||
macro_expansion_no,
|
||||
&exp_descriptor_c,
|
||||
c_parse,
|
||||
c_error,
|
||||
d_parse,
|
||||
d_error,
|
||||
null_post_parser,
|
||||
c_printchar, /* Print a character constant. */
|
||||
c_printstr, /* Function to print string constant. */
|
||||
|
|
|
@ -54,6 +54,12 @@ struct builtin_d_type
|
|||
struct type *builtin_dchar;
|
||||
};
|
||||
|
||||
/* Defined in d-exp.y. */
|
||||
|
||||
extern int d_parse (struct parser_state *);
|
||||
|
||||
extern void d_error (char *);
|
||||
|
||||
/* Defined in d-lang.c */
|
||||
|
||||
extern const char *d_main_name (void);
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2014-06-19 Iain Buclaw <ibuclaw@gdcproject.org>
|
||||
|
||||
* gdb.dlang/expression.exp: New file.
|
||||
|
||||
2014-06-19 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* gdb.threads/thread-execl.exp (do_test): New procedure, factored
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
# Copyright (C) 2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Test basic builtin types.
|
||||
# NOTE: The tests here intentionally do not require a D compiler.
|
||||
|
||||
load_lib "d-support.exp"
|
||||
|
||||
if { [skip_d_tests] } { continue }
|
||||
|
||||
proc test_d_integer_literals {} {
|
||||
# Test valid D integer literals are accepted.
|
||||
|
||||
gdb_test "print 123456" " = 123456"
|
||||
gdb_test "print 123_456" " = 123456"
|
||||
gdb_test "print 1_2_3_4_5_6_" " = 123456"
|
||||
|
||||
gdb_test "print 0x123456" " = 1193046"
|
||||
gdb_test "print 0x123_456" " = 1193046"
|
||||
gdb_test "print 0x1_2_3_4_5_6_" " = 1193046"
|
||||
|
||||
gdb_test "print 0123456" " = 42798"
|
||||
gdb_test "print 0123_456" " = 42798"
|
||||
gdb_test "print 01_2_3_4_5_6_" " = 42798"
|
||||
|
||||
gdb_test "print 0b101010" " = 42"
|
||||
gdb_test "print 0b101_010" " = 42"
|
||||
gdb_test "print 0b1_0_1_0_1_0_" " = 42"
|
||||
|
||||
# Usual decimal notation
|
||||
gdb_test "ptype 0" "type = int"
|
||||
gdb_test "ptype 2_147_483_647" "type = int"
|
||||
gdb_test "ptype 2_147_483_648" "type = long"
|
||||
gdb_test "ptype 4_294_967_296" "type = long"
|
||||
|
||||
# Explicit suffixes
|
||||
gdb_test "ptype 0L" "type = long"
|
||||
gdb_test "ptype 2_147_483_648U" "type = uint"
|
||||
gdb_test "ptype 4_294_967_296U" "type = ulong"
|
||||
gdb_test "ptype 0UL" "type = ulong"
|
||||
gdb_test "ptype 0LU" "type = ulong"
|
||||
|
||||
# Hexadecimal notation
|
||||
gdb_test "ptype 0x0" "type = int"
|
||||
gdb_test "ptype 0x7FFF_FFFF" "type = int"
|
||||
gdb_test "ptype 0x8000_0000" "type = uint"
|
||||
gdb_test "ptype 0x1_0000_0000" "type = long"
|
||||
|
||||
# Hexadecimal notation with explicit suffixes
|
||||
gdb_test "ptype 0x0L" "type = long"
|
||||
gdb_test "ptype 0x7FFF_FFFFU" "type = uint"
|
||||
gdb_test "ptype 0x1_0000_0000U" "type = ulong"
|
||||
gdb_test "ptype 0x0UL" "type = ulong"
|
||||
gdb_test "ptype 0x0LU" "type = ulong"
|
||||
|
||||
# Octal notation
|
||||
gdb_test "ptype 00" "type = int"
|
||||
gdb_test "ptype 017_777_777_777" "type = int"
|
||||
gdb_test "ptype 020_000_000_000" "type = uint"
|
||||
gdb_test "ptype 040_000_000_000" "type = long"
|
||||
|
||||
# Octal notation with explicit suffixes
|
||||
gdb_test "ptype 00L" "type = long"
|
||||
gdb_test "ptype 017_777_777_777U" "type = uint"
|
||||
gdb_test "ptype 040_000_000_000U" "type = ulong"
|
||||
gdb_test "ptype 00UL" "type = ulong"
|
||||
gdb_test "ptype 00LU" "type = ulong"
|
||||
|
||||
# Binary notation
|
||||
gdb_test "ptype 0b0" "type = int"
|
||||
gdb_test "ptype 0b1111111111111111111111111111111" "type = int"
|
||||
gdb_test "ptype 0b10000000000000000000000000000000" "type = uint"
|
||||
gdb_test "ptype 0b100000000000000000000000000000000" "type = long"
|
||||
|
||||
# Binary notation with explicit suffixes
|
||||
gdb_test "ptype 0b0L" "type = long"
|
||||
gdb_test "ptype 0b1111111111111111111111111111111U" "type = uint"
|
||||
gdb_test "ptype 0b100000000000000000000000000000000U" "type = ulong"
|
||||
gdb_test "ptype 0b0UL" "type = ulong"
|
||||
gdb_test "ptype 0b0LU" "type = ulong"
|
||||
}
|
||||
|
||||
proc test_d_float_literals {} {
|
||||
# Test valid D float literals are accepted.
|
||||
|
||||
gdb_test "ptype 123_456.567_8" "type = double"
|
||||
gdb_test "ptype 1_2_3_4_5_6_._5_6_7_8" "type = double"
|
||||
gdb_test "ptype 1_2_3_4_5_6_._5e-6_" "type = double"
|
||||
gdb_test "ptype 0x1.FFFFFFFFFFFFFp1023" "type = double"
|
||||
gdb_test "ptype 0x1p-52L" "type = real"
|
||||
gdb_test "ptype 1.175494351e-38F" "type = float"
|
||||
gdb_test "ptype 6.3i" "type = idouble"
|
||||
gdb_test "ptype 6.3fi" "type = ifloat"
|
||||
gdb_test "ptype 6.4Li" "type = ireal"
|
||||
}
|
||||
|
||||
proc test_d_expressions {} {
|
||||
# Test expression behaviour specific to D.
|
||||
|
||||
# Comparison and order expressions have same precedence.
|
||||
gdb_test "print 1 == 2 > 0" "A syntax error in expression, near `> 0'\."
|
||||
gdb_test "print (1 == 2) > 0" " = false"
|
||||
|
||||
# Exponent expressions
|
||||
gdb_test "print 5 ^^ 5" "3125"
|
||||
gdb_test "print 144 ^^ 0.5" "12"
|
||||
gdb_test "print (-10 ^^ 2)" "-100"
|
||||
gdb_test "print (-10) ^^ 2" "100"
|
||||
|
||||
gdb_test_no_output "set \$var = 144 ^^ 0.5" ""
|
||||
gdb_test "print \$var ^^= 2" "144"
|
||||
}
|
||||
|
||||
# Start with a fresh gdb.
|
||||
|
||||
gdb_exit
|
||||
gdb_start
|
||||
|
||||
if [set_lang_d] {
|
||||
test_d_integer_literals
|
||||
test_d_float_literals
|
||||
test_d_expressions
|
||||
} else {
|
||||
warning "D type tests suppressed."
|
||||
}
|
Loading…
Reference in New Issue