Thread: [pure-lang-svn] SF.net SVN: pure-lang: [45] pure/trunk/lexer.ll
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-05-04 07:10:34
|
Revision: 45
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=45&view=rev
Author: agraef
Date: 2008-05-04 00:10:41 -0700 (Sun, 04 May 2008)
Log Message:
-----------
Bugfix in parsing of bigint constants.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-05-04 07:09:25 UTC (rev 44)
+++ pure/trunk/lexer.ll 2008-05-04 07:10:41 UTC (rev 45)
@@ -607,7 +607,9 @@
{int}G {
mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t));
mpz_init(*z);
+ yytext[yyleng-1] = 0;
mpz_set_str(*z, yytext, 0);
+ yytext[yyleng-1] = 'G';
yylval->zval = z;
return token::BIGINT;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-05-10 19:37:29
|
Revision: 71
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=71&view=rev
Author: agraef
Date: 2008-05-10 12:37:36 -0700 (Sat, 10 May 2008)
Log Message:
-----------
Fix check for small int values, plug a related memleak in the lexer.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-05-10 19:34:15 UTC (rev 70)
+++ pure/trunk/lexer.ll 2008-05-10 19:37:36 UTC (rev 71)
@@ -594,9 +594,9 @@
mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t));
mpz_init(*z);
mpz_set_str(*z, yytext, 0);
- if (mpz_fits_slong_p(*z)) {
- long n = mpz_get_si(*z);
- free(z);
+ if (mpz_fits_sint_p(*z)) {
+ int n = mpz_get_si(*z);
+ mpz_clear(*z); free(z);
yylval->ival = n;
return token::INT;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-06-06 21:08:12
|
Revision: 190
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=190&view=rev
Author: agraef
Date: 2008-06-06 14:08:17 -0700 (Fri, 06 Jun 2008)
Log Message:
-----------
Fix glitch in output format (double 'extern').
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-06-06 20:04:23 UTC (rev 189)
+++ pure/trunk/lexer.ll 2008-06-06 21:08:17 UTC (rev 190)
@@ -375,7 +375,7 @@
if (jt == interp.globenv.end()) {
assert(xt != interp.externals.end());
const ExternInfo& info = xt->second;
- sout << "extern " << info << ";";
+ sout << info << ";";
if ((!sflag||lflag) && dflag) {
if (!sflag) sout << endl;
info.f->print(sout);
@@ -396,7 +396,7 @@
} else {
if (xt != interp.externals.end()) {
const ExternInfo& info = xt->second;
- sout << "extern " << info << ";";
+ sout << info << ";";
if ((!sflag||lflag) && dflag) {
if (!sflag) sout << endl;
info.f->print(sout);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-06-14 07:21:15
|
Revision: 217
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=217&view=rev
Author: agraef
Date: 2008-06-14 00:19:07 -0700 (Sat, 14 Jun 2008)
Log Message:
-----------
Check that value of PURE_MORE not only exists, but is also non-empty.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-06-14 06:59:34 UTC (rev 216)
+++ pure/trunk/lexer.ll 2008-06-14 07:19:07 UTC (rev 217)
@@ -451,7 +451,7 @@
FILE *fp;
const char *more = getenv("PURE_MORE");
// FIXME: We should check that 'more' actually exists here.
- if (more && isatty(fileno(stdin)) && (fp = popen(more, "w"))) {
+ if (more && *more && isatty(fileno(stdin)) && (fp = popen(more, "w"))) {
fputs(sout.str().c_str(), fp);
pclose(fp);
} else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-06-14 20:10:18
|
Revision: 232
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=232&view=rev
Author: agraef
Date: 2008-06-14 13:10:24 -0700 (Sat, 14 Jun 2008)
Log Message:
-----------
Add completion_matches command.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-06-14 19:37:36 UTC (rev 231)
+++ pure/trunk/lexer.ll 2008-06-14 20:10:24 UTC (rev 232)
@@ -122,6 +122,83 @@
{
return s.sym->s < t.sym->s;
}
+
+/* This is a watered-down version of the command completion routine from
+ pure.cc, used to implement the completion_matches command used by
+ pure-mode.el. This isn't perfect, since it will also complete command names
+ when not at the beginning of the line, but since the location inside the
+ line isn't passed to completion_matches, it's the best that we can do right
+ now. */
+
+static const char *commands[] = {
+ "cd", "clear", "extern", "help", "infix", "infixl", "infixr", "let", "list",
+ "ls", "nullary", "override", "postfix", "prefix", "pwd", "quit", "run",
+ "save", "stats", "underride", "using", 0
+};
+
+static char *
+command_generator(const char *text, int state)
+{
+ static int list_index, len;
+ static env::iterator it, end;
+ const char *name;
+
+ /* New match. */
+ if (!state) {
+ list_index = 0;
+ assert(interpreter::g_interp);
+ it = interpreter::g_interp->globenv.begin();
+ end = interpreter::g_interp->globenv.end();
+ len = strlen(text);
+ }
+
+ /* Return the next name which partially matches from the
+ command list. */
+ while ((name = commands[list_index])) {
+ list_index++;
+ if (strncmp(name, text, len) == 0)
+ return strdup(name);
+ }
+
+ /* Return the next name which partially matches from the
+ symbol list. */
+ while (it != end) {
+ assert(it->first > 0);
+ symbol& sym = interpreter::g_interp->symtab.sym(it->first);
+ it++;
+ if (strncmp(sym.s.c_str(), text, len) == 0)
+ return strdup(sym.s.c_str());
+ }
+
+ /* If no names matched, then return NULL. */
+ return 0;
+}
+
+static char **
+pure_completion(const char *text, int start, int end)
+{
+ return rl_completion_matches(text, command_generator);
+}
+
+static void list_completions(const char *s)
+{
+ char **matches = pure_completion(s, 0, strlen(s));
+ if (matches) {
+ if (matches[0])
+ if (!matches[1]) {
+ printf("%s\n", matches[0]);
+ free(matches[0]);
+ } else {
+ int i;
+ free(matches[0]);
+ for (i = 1; matches[i]; i++) {
+ printf("%s\n", matches[i]);
+ free(matches[i]);
+ }
+ }
+ free(matches);
+ }
+}
%}
%option noyywrap nounput debug
@@ -593,6 +670,15 @@
else
exit(0);
}
+^completion_matches.* {
+ // completion_matches command is only permitted in interactive mode
+ if (!interp.interactive) REJECT;
+ const char *s = yytext+18;
+ if (*s && !isspace(*s)) REJECT;
+ while (isspace(*s)) ++s;
+ yylloc->step();
+ list_completions(s);
+}
{int} {
mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-06-26 08:14:22
|
Revision: 313
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=313&view=rev
Author: agraef
Date: 2008-06-26 01:14:31 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
Add missing description of -d to list -h.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-06-25 23:02:21 UTC (rev 312)
+++ pure/trunk/lexer.ll 2008-06-26 08:14:31 UTC (rev 313)
@@ -365,6 +365,8 @@
Options may be combined, e.g., list -tvl is the same as list -t -v -l.\n\
-c Annotate printed definitions with compiled code snippets. Useful\n\
for debugging purposes.\n\
+-d Disassembles LLVM IR, showing the generated LLVM assembler code of a\n\
+ function.\n\
-e Annotate printed definitions with lexical environment information\n\
(de Bruijn indices, subterm paths). Useful for debugging purposes.\n\
-f Print information about function symbols only.\n\
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ag...@us...> - 2008-06-13 23:45:25
|
Revision: 213
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=213&view=rev
Author: agraef
Date: 2008-06-13 16:45:33 -0700 (Fri, 13 Jun 2008)
Log Message:
-----------
Only pipe 'list' output through more if stdin is a tty.
Modified Paths:
--------------
pure/trunk/lexer.ll
Modified: pure/trunk/lexer.ll
===================================================================
--- pure/trunk/lexer.ll 2008-06-13 19:02:09 UTC (rev 212)
+++ pure/trunk/lexer.ll 2008-06-13 23:45:33 UTC (rev 213)
@@ -448,9 +448,9 @@
else
sout << nfuns << " functions, " << nrules << " rules\n";
}
+ FILE *fp;
// FIXME: We should check that 'more' actually exists here.
- FILE *fp = popen("more", "w");
- if (fp) {
+ if (isatty(fileno(stdin)) && (fp = popen("more", "w"))) {
fputs(sout.str().c_str(), fp);
pclose(fp);
} else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|