summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/flex.texi8
-rw-r--r--tests/.gitignore36
-rw-r--r--tests/Makefile.am67
-rw-r--r--tests/README19
-rw-r--r--tests/mem_c99.l188
-rw-r--r--tests/mem_c99.txt25
-rw-r--r--tests/posix_c99.l80
-rw-r--r--tests/posix_cpp.l (renamed from tests/posix.l)0
-rw-r--r--tests/posixly_correct_c99.l80
-rw-r--r--tests/posixly_correct_cpp.l (renamed from tests/posixly_correct.l)0
-rw-r--r--tests/prefix_c99.l84
-rw-r--r--tests/prefix_c99.txt1
-rw-r--r--tests/quote_in_comment_c99.l17
-rw-r--r--tests/quote_in_comment_c99.txt (renamed from tests/quote_in_comment.txt)0
-rw-r--r--tests/quote_in_comment_cpp.l (renamed from tests/quote_in_comment.l)0
-rw-r--r--tests/quote_in_comment_cpp.txt1
-rw-r--r--tests/quotes_c99.l132
-rw-r--r--tests/quotes_c99.txt (renamed from tests/quotes.txt)0
-rw-r--r--tests/quotes_cpp.l (renamed from tests/quotes.l)0
-rw-r--r--tests/quotes_cpp.txt2
-rw-r--r--tests/string_c99.l104
-rw-r--r--tests/top.l3
-rw-r--r--tests/yyextra_c99.l121
-rw-r--r--tests/yyextra_c99.txt (renamed from tests/yyextra.txt)0
-rw-r--r--tests/yyextra_cpp.l (renamed from tests/yyextra.l)0
-rw-r--r--tests/yyextra_cpp.txt795
26 files changed, 1729 insertions, 34 deletions
diff --git a/doc/flex.texi b/doc/flex.texi
index c527fae..9453e6b 100644
--- a/doc/flex.texi
+++ b/doc/flex.texi
@@ -8786,6 +8786,14 @@ targets. Almost anything generally descended from Algol shouldn't be
much more difficult; this certainly includes the whole
Pascal/Modula/Oberon family.
+The C99 back end can be used for production, but it is really intended
+as a launch point to be cloned by people writing support for
+additional languages. Accordingly, it omits support for some features
+that can't be practically ported out of C in order to lower the
+complexity of what needs to be translated to a new target language.
+These features are: the Bison bridge, header generation, and loadable
+tables.
+
Some notes about the interesting part:
@itemize
diff --git a/tests/.gitignore b/tests/.gitignore
index a5441c3..11bbbfb 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -73,18 +73,26 @@ mem_nr
mem_nr.c
mem_r
mem_r.c
+mem_c99
+mem_c99.c
multiple_scanners_nr
multiple_scanners_nr_[12].[ch]
multiple_scanners_r
multiple_scanners_r_[12].[ch]
-posix
-posix.c
-posixly_correct
-posixly_correct.c
+posix_cpp
+posix_cpp.c
+posix_c99
+posix_c99.c
+posixly_correct_cpp
+posixly_correct_cpp.c
+posixly_correct_c99
+posixly_correct_c99.c
prefix_nr
prefix_nr.c
prefix_r
prefix_r.c
+prefix_c99
+prefix_c99.c
pthread.pthread
pthread.c
reject_nr.reject
@@ -99,18 +107,26 @@ rescan_nr.direct
rescan_nr.direct.c
rescan_r.direct
rescan_r.direct.c
-quote_in_comment
-quote_in_comment.c
-quotes
-quotes.c
+quote_in_comment_cpp
+quote_in_comment_cpp.c
+quote_in_comment_c99
+quote_in_comment_c99.c
+quotes_cpp
+quotes_cpp.c
+quotes_c99
+quotes_c99.c
string_nr
string_nr.c
string_r
string_r.c
+string_c99
+string_c99.c
top
top.[ch]
-yyextra
-yyextra.c
+yyextra_cpp
+yyextra_cpp.c
+yyextra_c99
+yyextra_c99.c
tableopts_*.c
*.opt
*.ser
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d01cd8..a5bcac6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,18 +88,25 @@ simple_tests = \
header_r \
mem_nr \
mem_r \
+ mem_c99 \
multiple_scanners_nr \
multiple_scanners_r \
- posix \
- posixly_correct \
+ posix_cpp \
+ posix_c99 \
+ posixly_correct_cpp \
+ posixly_correct_c99 \
prefix_nr \
prefix_r \
- quote_in_comment \
- quotes \
+ prefix_c99 \
+ quote_in_comment_cpp \
+ quote_in_comment_c99 \
+ quotes_cpp \
+ quotes_c99 \
string_nr \
- string_r \
+ string_c99 \
top \
- yyextra
+ yyextra_cpp \
+ yyextra_c99
reject_tests = \
reject_nr.reject \
@@ -127,7 +134,8 @@ ONE_TESTS = \
lineno_r.one \
lineno_trailing.one
-quote_in_comment_SOURCES = quote_in_comment.l
+quote_in_comment_cpp_SOURCES = quote_in_comment_cpp.l
+quote_in_comment_c99_SOURCES = quote_in_comment_c99.l
alloc_extra_cpp_SOURCES = alloc_extra_cpp.l
alloc_extra_c99_SOURCES = alloc_extra_c99.l
array_nr_SOURCES = array_nr.l
@@ -173,16 +181,21 @@ lineno_r_one_SOURCES = lineno_r.l
lineno_trailing_one_SOURCES = lineno_trailing.l
mem_nr_SOURCES = mem_nr.l
mem_r_SOURCES = mem_r.l
+mem_c99_SOURCES = mem_c99.l
multiple_scanners_nr_SOURCES = multiple_scanners_nr_main.c multiple_scanners_nr_1.l multiple_scanners_nr_2.l
nodist_multiple_scanners_nr_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h
multiple_scanners_r_SOURCES = multiple_scanners_r_main.c multiple_scanners_r_1.l multiple_scanners_r_2.l
nodist_multiple_scanners_r_SOURCES = multiple_scanners_nr_1.h multiple_scanners_nr_2.h
-posix_SOURCES = posix.l
-posixly_correct_SOURCES = posixly_correct.l
+posix_cpp_SOURCES = posix_cpp.l
+posix_c99_SOURCES = posix_c99.l
+posixly_correct_cpp__SOURCES = posixly_correct_cp.l
+posixly_correct_c99_SOURCES = posixly_correct_c99.l
prefix_nr_SOURCES = prefix_nr.l
prefix_r_SOURCES = prefix_r.l
+prefix_c99_SOURCES = prefix_c99.l
pthread_pthread_SOURCES = pthread.l
-quotes_SOURCES = quotes.l
+quotes_cpp_SOURCES = quotes_cpp.l
+quotes_c99_SOURCES = quotes_c99.l
reject_nr_reject_SOURCES = reject.l4
reject_r_reject_SOURCES = reject.l4
reject_ver_table_SOURCES = reject.l4
@@ -191,9 +204,11 @@ rescan_nr_direct_SOURCES = rescan_nr.direct.l
rescan_r_direct_SOURCES = rescan_r.direct.l
string_nr_SOURCES = string_nr.l
string_r_SOURCES = string_r.l
+string_c99_SOURCES = string_c99.l
top_SOURCES = top.l top_main.c
nodist_top_SOURCES = top.h
-yyextra_SOURCES = yyextra.l
+yyextra_cpp_SOURCES = yyextra_cpp.l
+yyextra_c99_SOURCES = yyextra_c99.l
# Normally, automake would distribute files built by flex. Since the
# point of the test suite is to test the files that flex builds, and
@@ -250,6 +265,7 @@ CLEANFILES = \
lineno_trailing.c \
mem_nr.c \
mem_r.c \
+ mem_c99.c \
multiple_scanners_nr_1.c \
multiple_scanners_nr_1.h \
multiple_scanners_nr_2.c \
@@ -258,13 +274,17 @@ CLEANFILES = \
multiple_scanners_r_1.h \
multiple_scanners_r_2.c \
multiple_scanners_r_2.h \
- posix.c \
- posixly_correct.c \
+ posix_cpp.c \
+ posix_c99.c \
+ posixly_correct_cpp.c \
+ posixly_correct_c99.c \
prefix_nr.c \
prefix_r.c \
+ prefix_c99.c \
pthread.c \
- quote_in_comment.c \
- quotes.c \
+ quote_in_comment_cpp.c \
+ quote_in_comment_c99.c \
+ quotes_cpp.c \
reject_nr.reject.c \
reject_r.reject.c \
reject_ser.table.c \
@@ -275,9 +295,11 @@ CLEANFILES = \
rescan_r.direct.c \
string_nr.c \
string_r.c \
+ string_c99.c \
top.c \
top.h \
- yyextra.c \
+ yyextra_cpp.c \
+ yyextra_c99.c \
$(tableopts_c) \
$(tableopts_tables)
@@ -327,8 +349,10 @@ EXTRA_DIST = \
lineno_trailing.one.txt \
mem_nr.txt \
mem_r.txt \
+ mem_c99.txt \
prefix_nr.txt \
prefix_r.txt \
+ prefix_c99.txt \
pthread_1.txt \
pthread_2.txt \
pthread_3.txt \
@@ -337,8 +361,10 @@ EXTRA_DIST = \
reject.txt \
rescan_nr.direct.txt \
rescan_r.direct.txt \
- quote_in_comment.txt \
- quotes.txt \
+ quote_in_comment_cpp.txt \
+ quote_in_comment_c99.txt \
+ quotes_cpp.txt \
+ quotes_c99.txt \
top.txt \
yyextra.txt \
tableopts.txt
@@ -424,7 +450,10 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c
@if test ! -f $@; then rm -f $<; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi
-posixly_correct.c: posixly_correct.l $(FLEX)
+posixly_correct_cpp.c: posixly_correct_cpp.l $(FLEX)
+ $(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $<
+
+posixly_correct_c99.c: posixly_correct_c99.l $(FLEX)
$(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $<
reject_nr.reject.c: reject.l4 $(FLEX)
diff --git a/tests/README b/tests/README
index 8112438..f24b895 100644
--- a/tests/README
+++ b/tests/README
@@ -8,10 +8,11 @@ this directory and its contents.
* STRUCTURE OF THE TEST SUITE
-The testsuite consists of a large number of tests. Usually the test is
-simply that a scanner consumes all the tokens fed to it from a text
-(.txt) file in a maching grammar, not allowing stray characters to
-echo through to stdout. This is how we avoid meeding explicit check files.
+The testsuite consists of a large number of tests. In a "simple test",
+the check is simply that a scanner consumes all the tokens fed to it
+from a text (.txt) file in a maching grammar, not allowing stray
+characters to echo through to stdout. This is how we avoid meeding
+explicit check files.
Each test is centered around a scanner known to work with the most
recent version of flex. In general, after you modify your copy of the
@@ -84,3 +85,13 @@ under different back ends. As new target languages are added these
groups of patallel tests will grow. Tests that are not part of one of
these series are usually of features supported on the default cpp
back end only.
+
+WHY SOME TESTS ARE MISSING
+
+The "top" test is backend-independent; what it's really testing
+is Flex's ability to accumulate and ship preamble code sections.
+
+The C99 is missing tests for the Bison bridge, header generation, and
+loadable tables because it omits those features in order to be a simpler
+starting point for wring new back ends.
+
diff --git a/tests/mem_c99.l b/tests/mem_c99.l
new file mode 100644
index 0000000..a6df306
--- /dev/null
+++ b/tests/mem_c99.l
@@ -0,0 +1,188 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* A template scanner file to build "scanner.c".
+ * The whole idea is to cause memory realloc by
+ * 1. pushing a lot on the condition stack, and
+ * 2. eating input greater than YY_BUF_SIZE
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+/* Insanely small read buffer. This pretty much guarantees at least one realloc. */
+#ifdef YY_BUF_SIZE
+#undef YY_BUF_SIZE
+#endif
+#define YY_BUF_SIZE 8
+
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain noyywrap noinput noyy_top_state
+%option warn stack nodefault reentrant
+%option noyyalloc noyyrealloc noyyfree
+
+%x parens
+
+%%
+
+<INITIAL>{
+"(" { printf("yy_push_state(parens)\n"); yy_push_state(parens,yyscanner); }
+len=[0-9]+ { printf("About read token where %s\n",yytext); }
+0+ { }
+.|\n { }
+}
+
+<parens>{
+"(" { printf("yy_push_state(parens)\n"); yy_push_state(parens,yyscanner); }
+")" { printf("yy_pop_state()\n");yy_pop_state(yyscanner);}
+[^()\n]+ { }
+.|\n { }
+}
+
+%%
+/* total memory allocated */
+static size_t total_mem=0;
+
+/* track the amount of memory for ptr. */
+struct memsz {
+ void* p;
+ size_t sz;
+};
+
+static struct memsz * ptrs=0; /* Array of pairs. */
+static int nptrs=0; /* Number of pairs in array. */
+static int arrsz=0; /* Capacity of array. */
+
+static void dump_mem(FILE* fp){
+ int i;
+ fprintf(fp,"\tptrs[%d] = {", nptrs);
+ for (i=0; i < arrsz; i++)
+ fprintf(fp," {%#lx,%ld},", (long)ptrs[i].p, (long)ptrs[i].sz);
+
+ fprintf(fp,"}\n");
+}
+
+void * testalloc(yy_size_t n , void* yyscanner)
+{
+ (void)yyscanner;
+
+ void * p;
+ int i;
+
+ total_mem += n;
+ p = malloc(n);
+
+ if( nptrs >= arrsz){
+ /* increase array size by 1 */
+ arrsz++;
+ ptrs = realloc(ptrs, (size_t) arrsz * sizeof(struct memsz));
+ ptrs[nptrs].p = 0;
+ ptrs[nptrs].sz = 0;
+ }
+
+ /* find a null slot */
+ for(i=0; i < arrsz ; i++)
+ if (ptrs[i].p == 0) {
+ ptrs[i].p = p;
+ ptrs[i].sz = n;
+ }
+
+ nptrs++;
+ printf("yyflex_alloc(%8ld) total=%8ld return=%#10lx\n",(long)n,(long)total_mem,(long)p);
+ dump_mem(stdout);
+ return p;
+}
+
+void * testrealloc(void* p, yy_size_t n , void* yyscanner)
+{
+ (void)yyscanner;
+
+ int i;
+ for (i=0; i < arrsz; i++)
+ if ( ptrs[i].p == p){
+ total_mem -= ptrs[i].sz;
+ total_mem += n;
+ ptrs[i].p = realloc(p, n);
+ ptrs[i].sz = n;
+
+ printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n",
+ (long)p,(long)n,(long)total_mem,(long)ptrs[i].p);
+ dump_mem(stdout);
+ return ptrs[i].p;
+ }
+
+ fprintf(stderr,"ERROR: yyflex_realloc could not locate pointer %#lx.\n",(long)p);
+ dump_mem(stdout);
+ exit(1);
+}
+
+void testfree(void* p , void* yyscanner)
+{
+ (void)yyscanner;
+
+ int i;
+ for (i=0; i < arrsz; i++)
+ if ( ptrs[i].p == p){
+ total_mem -= ptrs[i].sz;
+ free(p);
+ ptrs[i].p = 0;
+ ptrs[i].sz = 0;
+ nptrs--;
+ printf("yyflex_free(%#10lx) total=%8ld\n",(long)p,(long)total_mem);
+ dump_mem(stdout);
+ return;
+ }
+
+ fprintf(stderr,"ERROR: yyflex_free could not locate pointer %#lx.\n",(long)p);
+ dump_mem(stdout);
+ exit(1);
+}
+
+int main(void);
+
+int
+main (void)
+{
+ yyscan_t scanner;
+ arrsz = 1;
+ ptrs = calloc(1, sizeof(struct memsz));
+ nptrs = 0;
+
+ testlex_init(&scanner);
+ testset_in(stdin,scanner);
+ testset_out(stdout,scanner);
+ testlex(scanner);
+ testlex_destroy(scanner);
+ free(ptrs);
+
+ if ( nptrs > 0 || total_mem > 0){
+ fprintf(stderr,"Oops. Looks like a memory leak: nptrs=%d, unfreed memory=%ld\n",nptrs,(long)total_mem);
+ exit(1);
+ }
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/mem_c99.txt b/tests/mem_c99.txt
new file mode 100644
index 0000000..79aa16a
--- /dev/null
+++ b/tests/mem_c99.txt
@@ -0,0 +1,25 @@
+First we push a lot on the stack by nesting parenthesis:
+
+((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+(((((((((((((((((((((((((((((((((((((((((((
+
+(should be 200 states pushed here)
+
+))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+)))))))))))))))))))))))))))))))))))))))))))
+
+Now we match progressively bigger tokens to increase the read buffer:
+
+len=1 0
+len=2 00
+len=4 0000
+len=8 00000000
+len=16 0000000000000000
+len=32 00000000000000000000000000000000
+len=64 0000000000000000000000000000000000000000000000000000000000000000
+len=128 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+len=256 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+len=512 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+len=1024 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/tests/posix_c99.l b/tests/posix_c99.l
new file mode 100644
index 0000000..7f50492
--- /dev/null
+++ b/tests/posix_c99.l
@@ -0,0 +1,80 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* The goal of this test is to verify that we are getting the counter-intuitive
+ * posix behavior of the repeat operator `{}'.
+ *
+ * ab{3} - In traditional flex, this matches "abbb".
+ * In posix, this matches "ababab".
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+#define NUM_TESTS 1
+char * tests[NUM_TESTS] = { "ababab"};
+int main(void);
+
+int tests_ok[NUM_TESTS] = { 0 };
+
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain noyywrap noinput
+%option warn posix-compat
+
+
+%%
+
+ab{3} tests_ok[0] = 1; return 0;
+.|\n return 0;
+
+%%
+
+
+int main (void)
+{
+ YY_BUFFER_STATE state;
+ int i;
+
+ yyin = stdin;
+ yyout = stdout;
+
+ /* Run the tests */
+ for (i=0; i < NUM_TESTS; i++){
+ printf("Testing: test_scan_string(%s): ", tests[i]);
+ state = test_scan_string(tests[i]);
+ testlex();
+ yy_delete_buffer(state);
+ printf("... %s\n", tests_ok[i] ? "OK" : "FAILED");
+ }
+
+ for (i=0; i < NUM_TESTS; i++)
+ if (!tests_ok[i])
+ exit(1);
+
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/posix.l b/tests/posix_cpp.l
index f1851d8..f1851d8 100644
--- a/tests/posix.l
+++ b/tests/posix_cpp.l
diff --git a/tests/posixly_correct_c99.l b/tests/posixly_correct_c99.l
new file mode 100644
index 0000000..85e5258
--- /dev/null
+++ b/tests/posixly_correct_c99.l
@@ -0,0 +1,80 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* The goal of this test is to verify that we are getting the counter-intuitive
+ * posix behavior of the repeat operator `{}'.
+ *
+ * ab{3} - In traditional flex, this matches "abbb".
+ * In posix, this matches "ababab".
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+#define NUM_TESTS 1
+char * tests[NUM_TESTS] = { "ababab"};
+int main(void);
+
+int tests_ok[NUM_TESTS] = { 0 };
+
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain noyywrap noinput
+%option warn
+
+
+%%
+
+ab{3} tests_ok[0] = 1; return 0;
+.|\n return 0;
+
+%%
+
+
+int main (void)
+{
+ YY_BUFFER_STATE state;
+ int i;
+
+ yyin = stdin;
+ yyout = stdout;
+
+ /* Run the tests */
+ for (i=0; i < NUM_TESTS; i++){
+ printf("Testing: test_scan_string(%s): ", tests[i]);
+ state = test_scan_string(tests[i]);
+ testlex();
+ yy_delete_buffer(state);
+ printf("... %s\n", tests_ok[i] ? "OK" : "FAILED");
+ }
+
+ for (i=0; i < NUM_TESTS; i++)
+ if (!tests_ok[i])
+ exit(1);
+
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/posixly_correct.l b/tests/posixly_correct_cpp.l
index 715bb27..715bb27 100644
--- a/tests/posixly_correct.l
+++ b/tests/posixly_correct_cpp.l
diff --git a/tests/prefix_c99.l b/tests/prefix_c99.l
new file mode 100644
index 0000000..4baebea
--- /dev/null
+++ b/tests/prefix_c99.l
@@ -0,0 +1,84 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* Builds "scanner.c". */
+/* The scanner itself is a no-op. A successful compilation is all we want. */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+%}
+%option emit="c99"
+%option reentrant
+%option 8bit prefix="FOO"
+%option nounput nomain noyywrap noinput
+%option warn
+
+
+%%
+
+
+.|\n|\r {
+
+ /* Compile, but do not execute the following code. */
+ if( 0 ) {
+ FOO_create_buffer( (FILE*)0, 0, yyscanner);
+ FOO_delete_buffer( (YY_BUFFER_STATE)0, yyscanner);
+ FOO_flush_buffer( (YY_BUFFER_STATE)0, yyscanner);
+ FOO_init_buffer( (YY_BUFFER_STATE)0, (FILE*)0, yyscanner);
+ FOO_load_buffer_state( yyscanner);
+ FOO_scan_buffer( (char*)0, (yy_size_t)0, yyscanner);
+ FOO_scan_bytes( (yyconst char*)0, 0, yyscanner);
+ FOO_scan_string( (yyconst char*)0, yyscanner);
+ FOO_switch_to_buffer( (YY_BUFFER_STATE)0, yyscanner);
+ FOOrestart( (FILE*)0, (yyscan_t )0);
+
+ FOOget_extra( (yyscan_t )0 );
+ FOOget_in( (yyscan_t )0 );
+ FOOget_leng( (yyscan_t )0 );
+ FOOget_out( (yyscan_t )0 );
+ FOOget_text( (yyscan_t )0 );
+ FOOlex( (yyscan_t )0 );
+ FOOlex_destroy( (yyscan_t )0 );
+ FOOlex_init( (yyscan_t *)0 );
+ FOOset_extra( (void *)0, (yyscan_t )0 );
+ FOOset_in( (FILE*)0, (yyscan_t )0 );
+ FOOset_out( (FILE*)0, (yyscan_t )0 );
+ }
+ }
+%%
+
+int main(void);
+
+int
+main (void)
+{
+ yyscan_t scanner;
+ FOOlex_init( &scanner);
+ FOOlex( scanner);
+ FOOlex_destroy( scanner);
+ printf( "TEST RETURNING OK.\n");
+ return 0;
+}
+
diff --git a/tests/prefix_c99.txt b/tests/prefix_c99.txt
new file mode 100644
index 0000000..0e6c88f
--- /dev/null
+++ b/tests/prefix_c99.txt
@@ -0,0 +1 @@
+Dummy input.
diff --git a/tests/quote_in_comment_c99.l b/tests/quote_in_comment_c99.l
new file mode 100644
index 0000000..2d3db98
--- /dev/null
+++ b/tests/quote_in_comment_c99.l
@@ -0,0 +1,17 @@
+%option emit="c99"
+%option 8bit noyywrap
+%%
+.|\n { yyecho();
+ //' "
+ }
+%%
+int
+main (void)
+{
+ yyin = stdin;
+ yyout = stdout;
+ while (yylex())
+ ;
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/quote_in_comment.txt b/tests/quote_in_comment_c99.txt
index 9daeafb..9daeafb 100644
--- a/tests/quote_in_comment.txt
+++ b/tests/quote_in_comment_c99.txt
diff --git a/tests/quote_in_comment.l b/tests/quote_in_comment_cpp.l
index cb17e2f..cb17e2f 100644
--- a/tests/quote_in_comment.l
+++ b/tests/quote_in_comment_cpp.l
diff --git a/tests/quote_in_comment_cpp.txt b/tests/quote_in_comment_cpp.txt
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/quote_in_comment_cpp.txt
@@ -0,0 +1 @@
+test
diff --git a/tests/quotes_c99.l b/tests/quotes_c99.l
new file mode 100644
index 0000000..5784f2e
--- /dev/null
+++ b/tests/quotes_c99.l
@@ -0,0 +1,132 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/* The point of this test is to be sure our M4 madness does not
+ * interfere with user code. I particular, we are looking
+ * for instances of M4 quotes, [[ and ]], in here to make it through the flex
+ * machinery unscathed.
+ */
+
+/* sect 1 [ 1 ] TEST_XXX */
+/* sect 1 [[ 2 ]] TEST_XXX */
+/* sect 1 [[[ 3 ]]] TEST_XXX */
+/* sect 1 [[[[ 4 ]]]] TEST_XXX */
+/* sect 1 ]] unmatched [[ TEST_XXX */
+
+%{
+/* A template scanner file to build "scanner.c". */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include <assert.h>
+/*#include "parser.h" */
+
+/* sect 1 block [ 1 ] TEST_XXX */
+/* sect 1 block [[ 2 ]] TEST_XXX */
+/* sect 1 block [[[ 3 ]]] TEST_XXX */
+/* sect 1 block [[[[ 4 ]]]] TEST_XXX */
+/* sect 1 block ]] unmatched [[ TEST_XXX */
+
+static int a[1] = {0};
+static int b[1] = {0};
+static int c[1] = {0};
+
+static int foo (int i){
+ return a[b[c[i]]]; /* sect 1 code TEST_XXX */
+}
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain noyywrap noinput
+%option warn
+
+
+%%
+ /* indented code [ 1 ] */
+ /* indented code [[ 2 ]] */
+ /* indented code [[[ 3 ]]] */
+ /* indented code [[[[ 4 ]]]] */
+ /* indented code ]] unmatched [[ */
+%{
+// non-indented code [ 1 ]
+// non-indented code [[ 2 ]]
+// non-indented code [[[ 3 ]]]
+// non-indented code [[[[ 4 ]]]]
+%}
+
+a /* action comment [ 1 ] */ ;
+b /* action comment [[ 2 ]] */ ;
+c /* action comment [[[ 3 ]]] */ ;
+d /* action comment [[[[ 4 ]]]] */ ;
+e /* action comment ]] unmatched [[ */ ;
+f return 1+foo(a[b[c[0]]]);
+.|\n {
+
+#if 0
+ action code [ 1 ] TEST_XXX
+ action code [[ 2 ]] TEST_XXX
+ action code [[[ 3 ]]] TEST_XXX
+ action code [[[[ 4 ]]]] TEST_XXX
+ action code ]] unmatched [[ TEST_XXX
+#endif
+ /* action block [ 1 ] TEST_XXX */
+ /* action block [[ 2 ]] TEST_XXX */
+ /* action block [[[ 3 ]]] TEST_XXX */
+ /* action block [[[[ 4 ]]]] TEST_XXX */
+ /* action block ]] unmatched [[ TEST_XXX */
+ assert(!strcmp("[[ 2 ]]", "[""[ 2 ]""]"));
+ assert(!strcmp("[[[ 3 ]]]", "[""[""[ 3 ]""]""]"));
+ assert(!strcmp("[[[[ 4 ]]]]", "[""[""[""[ 4 ]""]""]""]"));
+ assert(!strcmp("]] unmatched [[", "]""] unmatched [""["));
+ assert(!strcmp("]]m4_define(alpha, beta)[[",
+ "]""]m4_""define(alpha, beta)[""["));
+ return 1+foo(a[b[c[0]]]); /* TEST_XXX */
+ }
+%%
+
+/* sect 3 [ 1 ] TEST_XXX */
+/* sect 3 [[ 2 ]] TEST_XXX */
+/* sect 3 [[[ 3 ]]] TEST_XXX */
+/* sect 3 [[[[ 4 ]]]] TEST_XXX */
+/* sect 3 ]] unmatched [[ TEST_XXX */
+static int bar (int i){
+ return c[b[a[i]]]; /* sect 3 code TEST_XXX */
+}
+int main(void);
+
+#define CONCAT_IDENTS(a, b) a##b
+int
+main (void)
+{
+ /* m4_m4exit(100) */
+ FILE *M4_YY_NOT_IN_HEADER = stdin;
+ yyin = CONCAT_IDENTS(M4_, YY_NOT_IN_HEADER);
+ yyout = stdout;
+ while (yylex())
+ ;
+ assert(!strcmp("YY_G( alpha)", "Y""Y_G( alpha)"));
+ printf("TEST RETURNING OK.\n");
+ return bar(0);
+}
+
diff --git a/tests/quotes.txt b/tests/quotes_c99.txt
index 7288a40..7288a40 100644
--- a/tests/quotes.txt
+++ b/tests/quotes_c99.txt
diff --git a/tests/quotes.l b/tests/quotes_cpp.l
index d1b97eb..d1b97eb 100644
--- a/tests/quotes.l
+++ b/tests/quotes_cpp.l
diff --git a/tests/quotes_cpp.txt b/tests/quotes_cpp.txt
new file mode 100644
index 0000000..7288a40
--- /dev/null
+++ b/tests/quotes_cpp.txt
@@ -0,0 +1,2 @@
+0000 foo 1111 foo 0000 bar
+0000 foo 1111 foo 0000 bar
diff --git a/tests/string_c99.l b/tests/string_c99.l
new file mode 100644
index 0000000..656ea18
--- /dev/null
+++ b/tests/string_c99.l
@@ -0,0 +1,104 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* A template scanner file to build "scanner.c". */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+#define NUMBER 200
+#define WORD 201
+
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain nodefault noyywrap noinput
+%option warn reentrant
+
+
+%%
+
+[[:space:]]+ { }
+[[:digit:]]+ { printf("NUMBER "); fflush(stdout);}
+[[:alpha:]]+ { printf("WORD "); fflush(stdout);}
+. {
+ fprintf(stderr,"*** Error: Unrecognized character '%c' while scanning.\n",
+ yytext[0]);
+ yyterminate();
+ }
+
+<<EOF>> { printf("<<EOF>>\n"); yyterminate();}
+
+%%
+
+
+#define INPUT_STRING_1 "1234 foo bar"
+#define INPUT_STRING_2 "1234 foo bar *@&@&###@^$#&#*"
+
+int main(void);
+
+int
+main (void)
+{
+ char * buf;
+ size_t len;
+ YY_BUFFER_STATE state;
+ yyscan_t scanner=NULL;
+
+
+ /* Scan a good string. */
+ printf("Testing: test_scan_string(%s): ",INPUT_STRING_1); fflush(stdout);
+ testlex_init(&scanner);
+ state = test_scan_string ( INPUT_STRING_1 ,scanner);
+ testlex(scanner);
+ test_delete_buffer(state, scanner);
+ testlex_destroy(scanner);
+
+ /* Scan only the first 12 chars of a string. */
+ printf("Testing: test_scan_bytes(%s): ",INPUT_STRING_2); fflush(stdout);
+ testlex_init(&scanner);
+ state = test_scan_bytes ( INPUT_STRING_2, 12 ,scanner);
+ testlex(scanner);
+ test_delete_buffer(state,scanner);
+ testlex_destroy(scanner);
+
+ /* Scan directly from a buffer.
+ We make a copy, since the buffer will be modified by flex.*/
+ printf("Testing: test_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
+ len = strlen(INPUT_STRING_1) + 2;
+ buf = malloc(len);
+ strcpy( buf, INPUT_STRING_1);
+ buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */
+ buf[ len -1 ] =0;
+
+ testlex_init(&scanner);
+ state = test_scan_buffer( buf, len ,scanner);
+ testlex(scanner);
+ test_delete_buffer(state,scanner);
+ testlex_destroy(scanner);
+
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/top.l b/tests/top.l
index 25f4773..cefb2e7 100644
--- a/tests/top.l
+++ b/tests/top.l
@@ -24,7 +24,8 @@
%{
/* Build "scanner.c".
The scanner is not important.
- This test is really about compilation. See "main.c".
+ This test is backend-independent; what it's really testing
+ is Flex's ability to accumulate and ship preamble code sections.
*/
#include <stdio.h>
#include <stdlib.h>
diff --git a/tests/yyextra_c99.l b/tests/yyextra_c99.l
new file mode 100644
index 0000000..66e2b4b
--- /dev/null
+++ b/tests/yyextra_c99.l
@@ -0,0 +1,121 @@
+/*
+ * This file is part of flex.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+%{
+/* A file to build "scanner.c". */
+/* This tests that we can use "yyextra".
+ We buffer all input into a growable array, then print it.
+ We run diff on the input and output.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+
+/* We'll store the entire input in this buffer, growing as necessary. */
+struct Buffer {
+ int curr_len;
+ int max_len;
+ int grow_len;
+ char * data;
+};
+
+/* Save char into junk array at next position. */
+static void append_char (char c, yyscan_t scanner );
+
+%}
+
+%option emit="c99"
+%option 8bit prefix="test"
+%option nounput nomain noyywrap nodefault noyyinput
+%option warn
+%option reentrant
+%option extra-type="struct Buffer *"
+
+%%
+
+.|\r|\n { append_char (yytext[0],yyscanner); }
+
+%%
+
+int main(void);
+
+int
+main (void)
+{
+ yyscan_t scanner;
+ struct Buffer * buf;
+ int i;
+
+ buf = malloc(sizeof(struct Buffer));
+ buf->curr_len =0;
+ buf->max_len = 4;
+ buf->grow_len = 100;
+ buf->data = malloc((size_t) buf->max_len);
+
+ testlex_init(&scanner);
+ testset_in( stdin, scanner);
+ testset_out( stdout, scanner);
+ testset_extra( buf, scanner );
+ testlex(scanner);
+
+ buf = testget_extra(scanner);
+ for(i=0; i < buf->curr_len; i++)
+ fputc( buf->data[i], stdout );
+ free( buf->data);
+ free( buf);
+
+ testlex_destroy(scanner);
+ return 0;
+}
+
+/* Save char into junk array at next position. */
+static void append_char (char c, yyscan_t scanner )
+{
+ struct Buffer *buf, *new_buf;
+ buf = testget_extra(scanner);
+
+ /* Grow buffer if necessary. */
+
+ if( buf->curr_len >= buf->max_len )
+ {
+ new_buf = malloc(sizeof(struct Buffer));
+ new_buf->max_len = buf->max_len + buf->grow_len;
+ new_buf->grow_len = buf->grow_len;
+ new_buf->data = malloc((size_t) new_buf->max_len);
+ for( new_buf->curr_len = 0;
+ new_buf->curr_len < buf->curr_len;
+ new_buf->curr_len++ )
+ {
+ new_buf->data[ new_buf->curr_len] = buf->data [ new_buf->curr_len];
+ }
+ free( buf->data );
+ free( buf );
+ buf = new_buf;
+ testset_extra( buf, scanner );
+ }
+
+
+ buf->data[ buf->curr_len++ ] = c;
+}
diff --git a/tests/yyextra.txt b/tests/yyextra_c99.txt
index 243df29..243df29 100644
--- a/tests/yyextra.txt
+++ b/tests/yyextra_c99.txt
diff --git a/tests/yyextra.l b/tests/yyextra_cpp.l
index 5a5a014..5a5a014 100644
--- a/tests/yyextra.l
+++ b/tests/yyextra_cpp.l
diff --git a/tests/yyextra_cpp.txt b/tests/yyextra_cpp.txt
new file mode 100644
index 0000000..243df29
--- /dev/null
+++ b/tests/yyextra_cpp.txt
@@ -0,0 +1,795 @@
+
+ THE UNITED STATES CONSTITUTION
+ _________________________________________________________________
+
+ (See Note 1)
+
+ We the People of the United States, in Order to form a more perfect
+ Union, establish Justice, insure domestic Tranquility, provide for the
+ common defence, promote the general Welfare, and secure the Blessings
+ of Liberty to ourselves and our Posterity, do ordain and establish
+ this Constitution for the United States of America.
+
+Article. I.
+
+ Section 1.
+
+ All legislative Powers herein granted shall be vested in a Congress of
+ the United States, which shall consist of a Senate and House of
+ Representatives.
+
+ Section. 2.
+
+ Clause 1: The House of Representatives shall be composed of Members
+ chosen every second Year by the People of the several States, and the
+ Electors in each State shall have the Qualifications requisite for
+ Electors of the most numerous Branch of the State Legislature.
+
+ Clause 2: No Person shall be a Representative who shall not have
+ attained to the Age of twenty five Years, and been seven Years a
+ Citizen of the United States, and who shall not, when elected, be an
+ Inhabitant of that State in which he shall be chosen.
+
+ Clause 3: Representatives and direct Taxes shall be apportioned among
+ the several States which may be included within this Union, according
+ to their respective Numbers, which shall be determined by adding to
+ the whole Number of free Persons, including those bound to Service for
+ a Term of Years, and excluding Indians not taxed, three fifths of all
+ other Persons. (See Note 2) The actual Enumeration shall be made
+ within three Years after the first Meeting of the Congress of the
+ United States, and within every subsequent Term of ten Years, in such
+ Manner as they shall by Law direct. The Number of Representatives
+ shall not exceed one for every thirty Thousand, but each State shall
+ have at Least one Representative; and until such enumeration shall be
+ made, the State of New Hampshire shall be entitled to chuse three,
+ Massachusetts eight, Rhode-Island and Providence Plantations one,
+ Connecticut five, New-York six, New Jersey four, Pennsylvania eight,
+ Delaware one, Maryland six, Virginia ten, North Carolina five, South
+ Carolina five, and Georgia three.
+
+ Clause 4: When vacancies happen in the Representation from any State,
+ the Executive Authority thereof shall issue Writs of Election to fill
+ such Vacancies.
+
+ Clause 5: The House of Representatives shall chuse their Speaker and
+ other Officers; and shall have the sole Power of Impeachment.
+
+ Section. 3.
+
+ Clause 1: The Senate of the United States shall be composed of two
+ Senators from each State, chosen by the Legislature thereof, (See Note
+ 3) for six Years; and each Senator shall have one Vote.
+
+ Clause 2: Immediately after they shall be assembled in Consequence of
+ the first Election, they shall be divided as equally as may be into
+ three Classes. The Seats of the Senators of the first Class shall be
+ vacated at the Expiration of the second Year, of the second Class at
+ the Expiration of the fourth Year, and of the third Class at the
+ Expiration of the sixth Year, so that one third may be chosen every
+ second Year; and if Vacancies happen by Resignation, or otherwise,
+ during the Recess of the Legislature of any State, the Executive
+ thereof may make temporary Appointments until the next Meeting of the
+ Legislature, which shall then fill such Vacancies. (See Note 4)
+
+ Clause 3: No Person shall be a Senator who shall not have attained to
+ the Age of thirty Years, and been nine Years a Citizen of the United
+ States, and who shall not, when elected, be an Inhabitant of that
+ State for which he shall be chosen.
+
+ Clause 4: The Vice President of the United States shall be President
+ of the Senate, but shall have no Vote, unless they be equally divided.
+
+ Clause 5: The Senate shall chuse their other Officers, and also a
+ President pro tempore, in the Absence of the Vice President, or when
+ he shall exercise the Office of President of the United States.
+
+ Clause 6: The Senate shall have the sole Power to try all
+ Impeachments. When sitting for that Purpose, they shall be on Oath or
+ Affirmation. When the President of the United States is tried, the
+ Chief Justice shall preside: And no Person shall be convicted without
+ the Concurrence of two thirds of the Members present.
+
+ Clause 7: Judgment in Cases of Impeachment shall not extend further
+ than to removal from Office, and disqualification to hold and enjoy
+ any Office of honor, Trust or Profit under the United States: but the
+ Party convicted shall nevertheless be liable and subject to
+ Indictment, Trial, Judgment and Punishment, according to Law.
+
+ Section. 4.
+
+ Clause 1: The Times, Places and Manner of holding Elections for
+ Senators and Representatives, shall be prescribed in each State by the
+ Legislature thereof; but the Congress may at any time by Law make or
+ alter such Regulations, except as to the Places of chusing Senators.
+
+ Clause 2: The Congress shall assemble at least once in every Year, and
+ such Meeting shall be on the first Monday in December, (See Note 5)
+ unless they shall by Law appoint a different Day.
+
+ Section. 5.
+
+ Clause 1: Each House shall be the Judge of the Elections, Returns and
+ Qualifications of its own Members, and a Majority of each shall
+ constitute a Quorum to do Business; but a smaller Number may adjourn
+ from day to day, and may be authorized to compel the Attendance of
+ absent Members, in such Manner, and under such Penalties as each House
+ may provide.
+
+ Clause 2: Each House may determine the Rules of its Proceedings,
+ punish its Members for disorderly Behaviour, and, with the Concurrence
+ of two thirds, expel a Member.
+
+ Clause 3: Each House shall keep a Journal of its Proceedings, and from
+ time to time publish the same, excepting such Parts as may in their
+ Judgment require Secrecy; and the Yeas and Nays of the Members of
+ either House on any question shall, at the Desire of one fifth of
+ those Present, be entered on the Journal.
+
+ Clause 4: Neither House, during the Session of Congress, shall,
+ without the Consent of the other, adjourn for more than three days,
+ nor to any other Place than that in which the two Houses shall be
+ sitting.
+
+ Section. 6.
+
+ Clause 1: The Senators and Representatives shall receive a
+ Compensation for their Services, to be ascertained by Law, and paid
+ out of the Treasury of the United States. (See Note 6) They shall in
+ all Cases, except Treason, Felony and Breach of the Peace,
+ beprivileged from Arrest during their Attendance at the Session of
+ their respective Houses, and in going to and returning from the same;
+ and for any Speech or Debate in either House, they shall not be
+ questioned in any other Place.
+
+ Clause 2: No Senator or Representative shall, during the Time for
+ which he was elected, be appointed to any civil Office under the
+ Authority of the United States, which shall have been created, or the
+ Emoluments whereof shall have been encreased during such time; and no
+ Person holding any Office under the United States, shall be a Member
+ of either House during his Continuance in Office.
+
+ Section. 7.
+
+ Clause 1: All Bills for raising Revenue shall originate in the House
+ of Representatives; but the Senate may propose or concur with
+ Amendments as on other Bills.
+
+ Clause 2: Every Bill which shall have passed the House of
+ Representatives and the Senate, shall, before it become a Law, be
+ presented to the President of the United States; If he approve he
+ shall sign it, but if not he shall return it, with his Objections to
+ that House in which it shall have originated, who shall enter the
+ Objections at large on their Journal, and proceed to reconsider it. If
+ after such Reconsideration two thirds of that House shall agree to
+ pass the Bill, it shall be sent, together with the Objections, to the
+ other House, by which it shall likewise be reconsidered, and if
+ approved by two thirds of that House, it shall become a Law. But in
+ all such Cases the Votes of both Houses shall be determined by yeas
+ and Nays, and the Names of the Persons voting for and against the Bill
+ shall be entered on the Journal of each House respectively. If any
+ Bill shall not be returned by the President within ten Days (Sundays
+ excepted) after it shall have been presented to him, the Same shall be
+ a Law, in like Manner as if he had signed it, unless the Congress by
+ their Adjournment prevent its Return, in which Case it shall not be a
+ Law.
+
+ Clause 3: Every Order, Resolution, or Vote to which the Concurrence of
+ the Senate and House of Representatives may be necessary (except on a
+ question of Adjournment) shall be presented to the President of the
+ United States; and before the Same shall take Effect, shall be
+ approved by him, or being disapproved by him, shall be repassed by two
+ thirds of the Senate and House of Representatives, according to the
+ Rules and Limitations prescribed in the Case of a Bill.
+
+ Section. 8.
+
+ Clause 1: The Congress shall have Power To lay and collect Taxes,
+ Duties, Imposts and Excises, to pay the Debts and provide for the
+ common Defence and general Welfare of the United States; but all
+ Duties, Imposts and Excises shall be uniform throughout the United
+ States;
+
+ Clause 2: To borrow Money on the credit of the United States;
+
+ Clause 3: To regulate Commerce with foreign Nations, and among the
+ several States, and with the Indian Tribes;
+
+ Clause 4: To establish an uniform Rule of Naturalization, and uniform
+ Laws on the subject of Bankruptcies throughout the United States;
+
+ Clause 5: To coin Money, regulate the Value thereof, and of foreign
+ Coin, and fix the Standard of Weights and Measures;
+
+ Clause 6: To provide for the Punishment of counterfeiting the
+ Securities and current Coin of the United States;
+
+ Clause 7: To establish Post Offices and post Roads;
+
+ Clause 8: To promote the Progress of Science and useful Arts, by
+ securing for limited Times to Authors and Inventors the exclusive
+ Right to their respective Writings and Discoveries;
+
+ Clause 9: To constitute Tribunals inferior to the supreme Court;
+
+ Clause 10: To define and punish Piracies and Felonies committed on the
+ high Seas, and Offences against the Law of Nations;
+
+ Clause 11: To declare War, grant Letters of Marque and Reprisal, and
+ make Rules concerning Captures on Land and Water;
+
+ Clause 12: To raise and support Armies, but no Appropriation of Money
+ to that Use shall be for a longer Term than two Years;
+
+ Clause 13: To provide and maintain a Navy;
+
+ Clause 14: To make Rules for the Government and Regulation of the land
+ and naval Forces;
+
+ Clause 15: To provide for calling forth the Militia to execute the
+ Laws of the Union, suppress Insurrections and repel Invasions;
+
+ Clause 16: To provide for organizing, arming, and disciplining, the
+ Militia, and for governing such Part of them as may be employed in the
+ Service of the United States, reserving to the States respectively,
+ the Appointment of the Officers, and the Authority of training the
+ Militia according to the discipline prescribed by Congress;
+
+ Clause 17: To exercise exclusive Legislation in all Cases whatsoever,
+ over such District (not exceeding ten Miles square) as may, byCession
+ of particular States, and the Acceptance of Congress, become the Seat
+ of the Government of the United States, and to exercise like Authority
+ over all Places purchased by the Consent of the Legislature of the
+ State in which the Same shall be, for the Erection of Forts,
+ Magazines, Arsenals, dock-Yards, and other needful Buildings;--And
+
+ Clause 18: To make all Laws which shall be necessary and proper for
+ carrying into Execution the foregoing Powers, and all other Powers
+ vested by this Constitution in the Government of the United States, or
+ in any Department or Officer thereof.
+
+ Section. 9.
+
+ Clause 1: The Migration or Importation of such Persons as any of the
+ States now existing shall think proper to admit, shall not be
+ prohibited by the Congress prior to the Year one thousand eight
+ hundred and eight, but a Tax or duty may be imposed on such
+ Importation, not exceeding ten dollars for each Person.
+
+ Clause 2: The Privilege of the Writ of Habeas Corpus shall not be
+ suspended, unless when in Cases of Rebellion or Invasion the public
+ Safety may require it.
+
+ Clause 3: No Bill of Attainder or ex post facto Law shall be passed.
+
+ Clause 4: No Capitation, or other direct, Tax shall be laid, unless in
+ Proportion to the Census or Enumeration herein before directed to be
+ taken. (See Note 7)
+
+ Clause 5: No Tax or Duty shall be laid on Articles exported from any
+ State.
+
+ Clause 6: No Preference shall be given by any Regulation of Commerce
+ or Revenue to the Ports of one State over those of another: nor shall
+ Vessels bound to, or from, one State, be obliged to enter, clear, or
+ pay Duties in another.
+
+ Clause 7: No Money shall be drawn from the Treasury, but in
+ Consequence of Appropriations made by Law; and a regular Statement and
+ Account of the Receipts and Expenditures of all public Money shall be
+ published from time to time.
+
+ Clause 8: No Title of Nobility shall be granted by the United States:
+ And no Person holding any Office of Profit or Trust under them, shall,
+ without the Consent of the Congress, accept of any present, Emolument,
+ Office, or Title, of any kind whatever, from any King, Prince, or
+ foreign State.
+
+ Section. 10.
+
+ Clause 1: No State shall enter into any Treaty, Alliance, or
+ Confederation; grant Letters of Marque and Reprisal; coin Money; emit
+ Bills of Credit; make any Thing but gold and silver Coin a Tender in
+ Payment of Debts; pass any Bill of Attainder, ex post facto Law, or
+ Law impairing the Obligation of Contracts, or grant any Title of
+ Nobility.
+
+ Clause 2: No State shall, without the Consent of the Congress, lay any
+ Imposts or Duties on Imports or Exports, except what may be absolutely
+ necessary for executing it's inspection Laws: and the net Produce of
+ all Duties and Imposts, laid by any State on Imports or Exports, shall
+ be for the Use of the Treasury of the United States; and all such Laws
+ shall be subject to the Revision and Controul of the Congress.
+
+ Clause 3: No State shall, without the Consent of Congress, lay any
+ Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter
+ into any Agreement or Compact with another State, or with a foreign
+ Power, or engage in War, unless actually invaded, or in such imminent
+ Danger as will not admit of delay.
+
+Article. II.
+
+ Section. 1.
+
+ Clause 1: The executive Power shall be vested in a President of the
+ United States of America. He shall hold his Office during the Term of
+ four Years, and, together with the Vice President, chosen for the same
+ Term, be elected, as follows
+
+ Clause 2: Each State shall appoint, in such Manner as the Legislature
+ thereof may direct, a Number of Electors, equal to the whole Number of
+ Senators and Representatives to which the State may be entitled in the
+ Congress: but no Senator or Representative, or Person holding an
+ Office of Trust or Profit under the United States, shall be appointed
+ an Elector.
+
+ Clause 3: The Electors shall meet in their respective States, and vote
+ by Ballot for two Persons, of whom one at least shall not be an
+ Inhabitant of the same State with themselves. And they shall make a
+ List of all the Persons voted for, and of the Number of Votes for
+ each; which List they shall sign and certify, and transmit sealed to
+ the Seat of the Government of the United States, directed to the
+ President of the Senate. The President of the Senate shall, in the
+ Presence of the Senate and House of Representatives, open all the
+ Certificates, and the Votes shall then be counted. The Person having
+ the greatest Number of Votes shall be the President, if such Number be
+ a Majority of the whole Number of Electors appointed; and if there be
+ more than one who have such Majority, and have an equal Number of
+ Votes, then the House of Representatives shall immediately chuse by
+ Ballot one of them for President; and if no Person have a Majority,
+ then from the five highest on the List the said House shall in like
+ Manner chuse the President. But in chusing the President, the Votes
+ shall be taken by States, the Representation from each State having
+ one Vote; A quorum for this Purpose shall consist of a Member or
+ Members from two thirds of the States, and a Majority of all the
+ States shall be necessary to a Choice. In every Case, after the Choice
+ of the President, the Person having the greatest Number of Votes of
+ the Electors shall be the Vice President. But if there should remain
+ two or more who have equal Votes, the Senate shall chuse from them by
+ Ballot the Vice President. (See Note 8)
+
+ Clause 4: The Congress may determine the Time of chusing the Electors,
+ and the Day on which they shall give their Votes; which Day shall be
+ the same throughout the United States.
+
+ Clause 5: No Person except a natural born Citizen, or a Citizen of the
+ United States, at the time of the Adoption of this Constitution, shall
+ be eligible to the Office of President; neither shall any Person be
+ eligible to that Office who shall not have attained to the Age of
+ thirty five Years, and been fourteen Years a Resident within the
+ United States.
+
+ Clause 6: In Case of the Removal of the President from Office, or of
+ his Death, Resignation, or Inability to discharge the Powers and
+ Duties of the said Office, (See Note 9) the Same shall devolve on the
+ VicePresident, and the Congress may by Law provide for the Case of
+ Removal, Death, Resignation or Inability, both of the President and
+ Vice President, declaring what Officer shall then act as President,
+ and such Officer shall act accordingly, until the Disability be
+ removed, or a President shall be elected.
+
+ Clause 7: The President shall, at stated Times, receive for his
+ Services, a Compensation, which shall neither be encreased nor
+ diminished during the Period for which he shall have been elected, and
+ he shall not receive within that Period any other Emolument from the
+ United States, or any of them.
+
+ Clause 8: Before he enter on the Execution of his Office, he shall
+ take the following Oath or Affirmation:--"I do solemnly swear (or
+ affirm) that I will faithfully execute the Office of President of the
+ United States, and will to the best of my Ability, preserve, protect
+ and defend the Constitution of the United States."
+
+ Section. 2.
+
+ Clause 1: The President shall be Commander in Chief of the Army and
+ Navy of the United States, and of the Militia of the several States,
+ when called into the actual Service of the United States; he may
+ require the Opinion, in writing, of the principal Officer in each of
+ the executive Departments, upon any Subject relating to the Duties of
+ their respective Offices, and he shall have Power to grant Reprieves
+ and Pardons for Offences against the United States, except in Cases of
+ Impeachment.
+
+ Clause 2: He shall have Power, by and with the Advice and Consent of
+ the Senate, to make Treaties, provided two thirds of the Senators
+ present concur; and he shall nominate, and by and with the Advice and
+ Consent of the Senate, shall appoint Ambassadors, other public
+ Ministers and Consuls, Judges of the supreme Court, and all other
+ Officers of the United States, whose Appointments are not herein
+ otherwise provided for, and which shall be established by Law: but the
+ Congress may by Law vest the Appointment of such inferior Officers, as
+ they think proper, in the President alone, in the Courts of Law, or in
+ the Heads of Departments.
+
+ Clause 3: The President shall have Power to fill up all Vacancies that
+ may happen during the Recess of the Senate, by granting Commissions
+ which shall expire at the End of their next Session.
+
+ Section. 3.
+
+ He shall from time to time give to the Congress Information of the
+ State of the Union, and recommend to their Consideration such Measures
+ as he shall judge necessary and expedient; he may, on extraordinary
+ Occasions, convene both Houses, or either of them, and in Case of
+ Disagreement between them, with Respect to the Time of Adjournment, he
+ may adjourn them to such Time as he shall think proper; he shall
+ receive Ambassadors and other public Ministers; he shall take Care
+ that the Laws be faithfully executed, and shall Commission all the
+ Officers of the United States.
+
+ Section. 4.
+
+ The President, Vice President and all civil Officers of the United
+ States, shall be removed from Office on Impeachment for, and
+ Conviction of, Treason, Bribery, or other high Crimes and
+ Misdemeanors.
+
+Article. III.
+
+ Section. 1.
+
+ The judicial Power of the United States, shall be vested in one
+ supreme Court, and in such inferior Courts as the Congress may from
+ time to time ordain and establish. The Judges, both of the supreme and
+ inferior Courts, shall hold their Offices during good Behaviour, and
+ shall, at stated Times, receive for their Services, a Compensation,
+ which shall not be diminished during their Continuance in Office.
+
+ Section. 2.
+
+ Clause 1: The judicial Power shall extend to all Cases, in Law and
+ Equity, arising under this Constitution, the Laws of the United
+ States, and Treaties made, or which shall be made, under their
+ Authority;--to all Cases affecting Ambassadors, other public Ministers
+ and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to
+ Controversies to which the United States shall be a Party;--to
+ Controversies between two or more States;--between a State and
+ Citizens of another State; (See Note 10)--between Citizens of
+ different States, --between Citizens of the same State claiming Lands
+ under Grants of different States, and between a State, or the Citizens
+ thereof, and foreign States, Citizens or Subjects.
+
+ Clause 2: In all Cases affecting Ambassadors, other public Ministers
+ and Consuls, and those in which a State shall be Party, the supreme
+ Court shall have original Jurisdiction. In all the other Cases before
+ mentioned, the supreme Court shall have appellate Jurisdiction, both
+ as to Law and Fact, with such Exceptions, and under such Regulations
+ as the Congress shall make.
+
+ Clause 3: The Trial of all Crimes, except in Cases of Impeachment,
+ shall be by Jury; and such Trial shall be held in the State where the
+ said Crimes shall have been committed; but when not committed within
+ any State, the Trial shall be at such Place or Places as the Congress
+ may by Law have directed.
+
+ Section. 3.
+
+ Clause 1: Treason against the United States, shall consist only in
+ levying War against them, or in adhering to their Enemies, giving them
+ Aid and Comfort. No Person shall be convicted of Treason unless on the
+ Testimony of two Witnesses to the same overt Act, or on Confession in
+ open Court.
+
+ Clause 2: The Congress shall have Power to declare the Punishment of
+ Treason, but no Attainder of Treason shall work Corruption of Blood,
+ or Forfeiture except during the Life of the Person attainted.
+
+Article. IV.
+
+ Section. 1.
+
+ Full Faith and Credit shall be given in each State to the public Acts,
+ Records, and judicial Proceedings of every other State. And the
+ Congress may by general Laws prescribe the Manner in which such Acts,
+ Records and Proceedings shall be proved, and the Effect thereof.
+
+ Section. 2.
+
+ Clause 1: The Citizens of each State shall be entitled to all
+ Privileges and Immunities of Citizens in the several States.
+
+ Clause 2: A Person charged in any State with Treason, Felony, or other
+ Crime, who shall flee from Justice, and be found in another State,
+ shall on Demand of the executive Authority of the State from which he
+ fled, be delivered up, to be removed to the State having Jurisdiction
+ of the Crime.
+
+ Clause 3: No Person held to Service or Labour in one State, under the
+ Laws thereof, escaping into another, shall, in Consequence of any Law
+ or Regulation therein, be discharged from such Service or Labour, but
+ shall be delivered up on Claim of the Party to whom such Service or
+ Labour may be due. (See Note 11)
+
+ Section. 3.
+
+ Clause 1: New States may be admitted by the Congress into this Union;
+ but no new State shall be formed or erected within the Jurisdiction of
+ any other State; nor any State be formed by the Junction of two or
+ more States, or Parts of States, without the Consent of the
+ Legislatures of the States concerned as well as of the Congress.
+
+ Clause 2: The Congress shall have Power to dispose of and make all
+ needful Rules and Regulations respecting the Territory or other
+ Property belonging to the United States; and nothing in this
+ Constitution shall be so construed as to Prejudice any Claims of the
+ United States, or of any particular State.
+
+ Section. 4.
+
+ The United States shall guarantee to every State in this Union a
+ Republican Form of Government, and shall protect each of them against
+ Invasion; and on Application of the Legislature, or of the Executive
+ (when the Legislature cannot be convened) against domestic Violence.
+
+Article. V.
+
+ The Congress, whenever two thirds of both Houses shall deem it
+ necessary, shall propose [1]Amendments to this Constitution, or, on
+ the Application of the Legislatures of two thirds of the several
+ States, shall call a Convention for proposing Amendments, which, in
+ either Case, shall be valid to all Intents and Purposes, as Part of
+ this Constitution, when ratified by the Legislatures of three fourths
+ of the several States, or by Conventions in three fourths thereof, as
+ the one or the other Mode of Ratification may be proposed by the
+ Congress; Provided that no Amendment which may be made prior to the
+ Year One thousand eight hundred and eight shall in any Manner affect
+ the first and fourth Clauses in the Ninth Section of the first
+ Article; and that no State, without its Consent, shall be deprived of
+ its equal Suffrage in the Senate.
+
+Article. VI.
+
+ Clause 1: All Debts contracted and Engagements entered into, before
+ the Adoption of this Constitution, shall be as valid against the
+ United States under this Constitution, as under the Confederation.
+
+ Clause 2: This Constitution, and the Laws of the United States which
+ shall be made in Pursuance thereof; and all Treaties made, or which
+ shall be made, under the Authority of the United States, shall be the
+ supreme Law of the Land; and the Judges in every State shall be bound
+ thereby, any Thing in the Constitution or Laws of any State to the
+ Contrary notwithstanding.
+
+ Clause 3: The Senators and Representatives before mentioned, and the
+ Members of the several State Legislatures, and all executive and
+ judicial Officers, both of the United States and of the several
+ States, shall be bound by Oath or Affirmation, to support this
+ Constitution; but no religious Test shall ever be required as a
+ Qualification to any Office or public Trust under the United States.
+
+Article. VII.
+
+ The Ratification of the Conventions of nine States, shall be
+ sufficient for the Establishment of this Constitution between the
+ States so ratifying the Same.
+
+ done in Convention by the Unanimous Consent of the States present the
+ Seventeenth Day of September in the Year of our Lord one thousand
+ seven hundred and Eighty seven and of the Independence of the United
+ States of America the Twelfth In witness whereof We have hereunto
+ subscribed our Names,
+
+ GO WASHINGTON--Presidt. and deputy from Virginia
+
+ [Signed also by the deputies of twelve States.]
+
+ Delaware
+
+ Geo: Read
+ Gunning Bedford jun
+ John Dickinson
+ Richard Bassett
+ Jaco: Broom
+
+ Maryland
+
+ James MCHenry
+ Dan of ST ThoS. Jenifer
+ DanL Carroll.
+
+ Virginia
+
+ John Blair--
+ James Madison Jr.
+
+ North Carolina
+
+ WM Blount
+ RichD. Dobbs Spaight.
+ Hu Williamson
+
+ South Carolina
+
+ J. Rutledge
+ Charles 1ACotesworth Pinckney
+ Charles Pinckney
+ Pierce Butler.
+
+ Georgia
+
+ William Few
+ Abr Baldwin
+
+ New Hampshire
+
+ John Langdon
+ Nicholas Gilman
+
+ Massachusetts
+
+ Nathaniel Gorham
+ Rufus King
+
+ Connecticut
+ WM. SamL. Johnson
+ Roger Sherman
+
+ New York
+
+ Alexander Hamilton
+
+ New Jersey
+
+ Wil: Livingston
+ David Brearley.
+ WM. Paterson.
+ Jona: Dayton
+
+ Pennsylvania
+
+ B Franklin
+ Thomas Mifflin
+ RobT Morris
+ Geo. Clymer
+ ThoS. FitzSimons
+ Jared Ingersoll
+ James Wilson.
+ Gouv Morris
+
+ Attest William Jackson Secretary
+
+ NOTES
+
+ Note 1: This text of the Constitution follows the engrossed copy
+ signed by Gen. Washington and the deputies from 12 States. The small
+ superior figures preceding the paragraphs designate Clauses, and were
+ not in the original and have no reference to footnotes.
+
+ The Constitution was adopted by a convention of the States on
+ September 17, 1787, and was subsequently ratified by the several
+ States, on the following dates: Delaware, December 7, 1787;
+ Pennsylvania, December 12, 1787; New Jersey, December 18, 1787;
+ Georgia, January 2, 1788; Connecticut, January 9, 1788; Massachusetts,
+ February 6, 1788; Maryland, April 28, 1788; South Carolina, May 23,
+ 1788; New Hampshire, June 21, 1788.
+
+ Ratification was completed on June 21, 1788.
+
+ The Constitution was subsequently ratified by Virginia, June 25, 1788;
+ New York, July 26, 1788; North Carolina, November 21, 1789; Rhode
+ Island, May 29, 1790; and Vermont, January 10, 1791.
+
+ In May 1785, a committee of Congress made a report recommending an
+ alteration in the Articles of Confederation, but no action was taken
+ on it, and it was left to the State Legislatures to proceed in the
+ matter. In January 1786, the Legislature of Virginia passed a
+ resolution providing for the appointment of five commissioners, who,
+ or any three of them, should meet such commissioners as might be
+ appointed in the other States of the Union, at a time and place to be
+ agreed upon, to take into consideration the trade of the United
+ States; to consider how far a uniform system in their commercial
+ regulations may be necessary to their common interest and their
+ permanent harmony; and to report to the several States such an act,
+ relative to this great object, as, when ratified by them, will enable
+ the United States in Congress effectually to provide for the same. The
+ Virginia commissioners, after some correspondence, fixed the first
+ Monday in September as the time, and the city of Annapolis as the
+ place for the meeting, but only four other States were represented,
+ viz: Delaware, New York, New Jersey, and Pennsylvania; the
+ commissioners appointed by Massachusetts, New Hampshire, North
+ Carolina, and Rhode Island failed to attend. Under the circumstances
+ of so partial a representation, the commissioners present agreed upon
+ a report, (drawn by Mr. Hamilton, of New York,) expressing their
+ unanimous conviction that it might essentially tend to advance the
+ interests of the Union if the States by which they were respectively
+ delegated would concur, and use their endeavors to procure the
+ concurrence of the other States, in the appointment of commissioners
+ to meet at Philadelphia on the Second Monday of May following, to take
+ into consideration the situation of the United States; to devise such
+ further provisions as should appear to them necessary to render the
+ Constitution of the Federal Government adequate to the exigencies of
+ the Union; and to report such an act for that purpose to the United
+ States in Congress assembled as, when agreed to by them and afterwards
+ confirmed by the Legislatures of every State, would effectually
+ provide for the same.
+
+ Congress, on the 21st of February, 1787, adopted a resolution in favor
+ of a convention, and the Legislatures of those States which had not
+ already done so (with the exception of Rhode Island) promptly
+ appointed delegates. On the 25th of May, seven States having convened,
+ George Washington, of Virginia, was unanimously elected President, and
+ the consideration of the proposed constitution was commenced. On the
+ 17th of September, 1787, the Constitution as engrossed and agreed upon
+ was signed by all the members present, except Mr. Gerry of
+ Massachusetts, and Messrs. Mason and Randolph, of Virginia. The
+ president of the convention transmitted it to Congress, with a
+ resolution stating how the proposed Federal Government should be put
+ in operation, and an explanatory letter. Congress, on the 28th of
+ September, 1787, directed the Constitution so framed, with the
+ resolutions and letter concerning the same, to "be transmitted to the
+ several Legislatures in order to be submitted to a convention of
+ delegates chosen in each State by the people thereof, in conformity to
+ the resolves of the convention."
+
+ On the 4th of March, 1789, the day which had been fixed for commencing
+ the operations of Government under the new Constitution, it had been
+ ratified by the conventions chosen in each State to consider it, as
+ follows: Delaware, December 7, 1787; Pennsylvania, December 12, 1787;
+ New Jersey, December 18, 1787; Georgia, January 2, 1788; Connecticut,
+ January 9, 1788; Massachusetts, February 6, 1788; Maryland, April 28,
+ 1788; South Carolina, May 23, 1788; New Hampshire, June 21, 1788;
+ Virginia, June 25, 1788; and New York, July 26, 1788.
+
+ The President informed Congress, on the 28th of January, 1790, that
+ North Carolina had ratified the Constitution November 21, 1789; and he
+ informed Congress on the 1st of June, 1790, that Rhode Island had
+ ratified the Constitution May 29, 1790. Vermont, in convention,
+ ratified the Constitution January 10, 1791, and was, by an act of
+ Congress approved February 18, 1791, "received and admitted into this
+ Union as a new and entire member of the United States."
+
+ Note 2: The part of this Clause relating to the mode of apportionment
+ of representatives among the several States has been affected by
+ Section 2 of amendment XIV, and as to taxes on incomes without
+ apportionment by amendment XVI.
+
+ Note 3: This Clause has been affected by Clause 1 of amendment XVII.
+
+ Note 4: This Clause has been affected by Clause 2 of amendment XVIII.
+
+ Note 5: This Clause has been affected by amendment XX.
+
+ Note 6: This Clause has been affected by amendment XXVII.
+
+ Note 7: This Clause has been affected by amendment XVI.
+
+ Note 8: This Clause has been superseded by amendment XII.
+
+ Note 9: This Clause has been affected by amendment XXV.
+
+ Note 10: This Clause has been affected by amendment XI.
+
+ Note 11: This Clause has been affected by amendment XIII.
+
+ Note 12: The first ten amendments to the Constitution of the United
+ States (and two others, one of which failed of ratification and the
+ other which later became the 27th amendment) were proposed to the
+ legislatures of the several States by the First Congress on September
+ 25, 1789. The first ten amendments were ratified by the following
+ States, and the notifications of ratification by the Governors thereof
+ were successively communicated by the President to Congress: New
+ Jersey, November 20, 1789; Maryland, December 19, 1789; North
+ Carolina, December 22, 1789; South Carolina, January 19, 1790; New
+ Hampshire, January 25, 1790; Delaware, January 28, 1790; New York,
+ February 24, 1790; Pennsylvania, March 10, 1790; Rhode Island, June 7,
+ 1790; Vermont, November 3, 1791; and Virginia, December 15, 1791.
+
+ Ratification was completed on December 15, 1791.
+
+ The amendments were subsequently ratified by the legislatures of
+ Massachusetts, March 2, 1939; Georgia, March 18, 1939; and
+ Connecticut, April 19, 1939.
+
+ Note 13: Only the 13th, 14th, 15th, and 16th articles of amendment had
+ numbers assigned to them at the time of ratification.
+
+ Note 14: This sentence has been superseded by section 3 of amendment
+ XX.
+
+ Note 15: See amendment XIX and section 1 of amendment XXVI.
+
+ Note 16: Repealed by section 1 of amendment XXI.
+
+References
+
+ 1. http://www.house.gov/Constitution/Amend.html