The Lemon program is an LALR(1) parser generator. It takes a context

free grammar  and converts it into  a subroutine that will  parse a file
using that grammar.

Lemon is  similar to the much  more famous programs "YACC"  and "BISON".
But lemon is not compatible with either yacc or bison. There are several
important differences:

	. Lemon using a different grammar  syntax which is less prone to
	  programming errors.

	. Lemon generates a parser that is faster than Yacc or Bison
	  parsers (according to the author).

	. The parser generated by Lemon is both re-entrant and thread-safe.

	. Lemon includes the concept of a non-terminal destructor, which
	  makes  it much  easier  to write  a parser  that  does not
	  leak memory.

WWW: http://www.hwaci.com/sw/lemon/
This commit is contained in:
Mikhail Teterin 2001-06-05 03:48:42 +00:00
parent 3eb9ee55c5
commit 258dab36c2
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=43506
7 changed files with 160 additions and 0 deletions

View file

@ -179,6 +179,7 @@
SUBDIR += kpp
SUBDIR += ktranslator
SUBDIR += lclint
SUBDIR += lemon
SUBDIR += libPropList
SUBDIR += libU77
SUBDIR += libcache

32
devel/lemon/Makefile Normal file
View file

@ -0,0 +1,32 @@
# Ports collection makefile for: lemon
# Date created: June 4, 2001
# Whom: Mikhail Teterin
#
# $FreeBSD$
#
PORTNAME= lemon
PORTVERSION= 1.0
CATEGORIES= devel
MASTER_SITES= http://www.hwaci.com/sw/lemon/
DISTFILES= lemon.c lempar.c
MAINTAINER= mi@aldan.algebra.com
NO_WRKSUBDIR= YES
do-extract:
${MKDIR} ${WRKSRC}
${CP} -p ${DISTDIR}/lemon.c ${WRKSRC}
do-build:
cd ${WRKSRC} && ${MAKE} VPATH=${DISTDIR} PROG=lemon NOMAN=1 \
CFLAGS="${CFLAGS} -DLEMPAR='\"${PREFIX}/share/lemon/lempar.c\"'" \
-f bsd.prog.mk
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/${PORTNAME} ${PREFIX}/bin/
${MKDIR} ${PREFIX}/share/lemon
${INSTALL_DATA} ${DISTDIR}/lempar.c ${PREFIX}/share/lemon/
.include <bsd.port.mk>

2
devel/lemon/distinfo Normal file
View file

@ -0,0 +1,2 @@
MD5 (lemon.c) = 926bc7eb6e5ee8f02e919cc0fe2febd6
MD5 (lempar.c) = 19c9e510be0b6bde25f945aecc79a97b

100
devel/lemon/files/patch-aa Normal file
View file

@ -0,0 +1,100 @@
--- /usr/ports/distfiles/lemon.c Tue Dec 5 20:52:24 2000
+++ ./lemon.c Mon Jun 4 23:35:15 2001
@@ -31,2 +31,5 @@
#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/param.h>
@@ -35,4 +38,2 @@
extern long strtol();
-extern void free();
-extern int access();
extern int atoi();
@@ -55,3 +56,2 @@
char *msort();
-extern void *malloc();
@@ -2525,45 +2525,13 @@
-/* Search for the file "name" which is in the same directory as
-** the exacutable */
-PRIVATE char *pathsearch(argv0,name,modemask)
-char *argv0;
-char *name;
-int modemask;
+PRIVATE const char *pathsearch()
{
- char *pathlist;
- char *path,*cp;
- char c;
- extern int access();
+ const char *path;
-#ifdef __WIN32__
- cp = strrchr(argv0,'\\');
-#else
- cp = strrchr(argv0,'/');
-#endif
- if( cp ){
- c = *cp;
- *cp = 0;
- path = (char *)malloc( strlen(argv0) + strlen(name) + 2 );
- if( path ) sprintf(path,"%s/%s",argv0,name);
- *cp = c;
- }else{
- extern char *getenv();
- pathlist = getenv("PATH");
- if( pathlist==0 ) pathlist = ".:/bin:/usr/bin";
- path = (char *)malloc( strlen(pathlist)+strlen(name)+2 );
- if( path!=0 ){
- while( *pathlist ){
- cp = strchr(pathlist,':');
- if( cp==0 ) cp = &pathlist[strlen(pathlist)];
- c = *cp;
- *cp = 0;
- sprintf(path,"%s/%s",pathlist,name);
- *cp = c;
- if( c==0 ) pathlist = "";
- else pathlist = &cp[1];
- if( access(path,modemask)==0 ) break;
- }
- }
- }
- return path;
+ path = getenv("LEMPAR");
+
+ if (path)
+ if (access(path, R_OK)) perror(path);
+ else return(path);
+
+ return(LEMPAR);
}
@@ -2631,6 +2599,5 @@
{
- static char templatename[] = "lempar.c";
- char buf[1000];
+ char buf[MAXPATHLEN];
FILE *in;
- char *tpltname;
+ const char *tpltname;
char *cp;
@@ -2643,10 +2610,9 @@
}
- if( access(buf,004)==0 ){
+ if( access(buf, R_OK)==0 ){
tpltname = buf;
}else{
- tpltname = pathsearch(lemp->argv0,templatename,0);
+ tpltname = pathsearch();
}
if( tpltname==0 ){
- fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
- templatename);
+ fprintf(stderr,"Can't find the parser driver template file.\n");
lemp->errorcnt++;
@@ -2656,3 +2622,3 @@
if( in==0 ){
- fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
+ fprintf(stderr,"Can't open the template file \"%s\".\n", tpltname);
lemp->errorcnt++;

1
devel/lemon/pkg-comment Normal file
View file

@ -0,0 +1 @@
An LALR(1) parser generator. Similar in function to yacc and bison

21
devel/lemon/pkg-descr Normal file
View file

@ -0,0 +1,21 @@
The Lemon program is an LALR(1) parser generator. It takes a context
free grammar and converts it into a subroutine that will parse a file
using that grammar.
Lemon is similar to the much more famous programs "YACC" and "BISON".
But lemon is not compatible with either yacc or bison. There are several
important differences:
. Lemon using a different grammar syntax which is less prone to
programming errors.
. Lemon generates a parser that is faster than Yacc or Bison
parsers (according to the author).
. The parser generated by Lemon is both re-entrant and thread-safe.
. Lemon includes the concept of a non-terminal destructor, which
makes it much easier to write a parser that does not
leak memory.
WWW: http://www.hwaci.com/sw/lemon/

3
devel/lemon/pkg-plist Normal file
View file

@ -0,0 +1,3 @@
bin/lemon
share/lemon/lempar.c
@dirrm share/lemon