トップページ⇒prog
37コメント21KB

flex++

■ このスレッドは過去ログ倉庫に格納されています
0001名無しさん@1周年NGNG
Win32用の flex++@` bison++ って存在するのでしょうか?
やっとみつけたのは16bit版でした。
0002名無しさん@1周年NGNG
cygwinに入ってるんじゃないかな?
http://sourceware.cygnus.com/cygwin/
0003名無しさん@1周年NGNG
コンパイルし直して、使うのはだめ?
0004名無しさん@1周年NGNG
flex++@`bison++ は初耳です。
flex の C++ 出力オプションとは異なるものなのでしょうか?
興味あります。こちらからお願いしてすみませんが、
よろしければ詳しいことを教えていただけませんか? > 1
0005名無しさん@1周年NGNG
>2
cygwin beta-20 を見てみたのですが、flex++ はありましたが
bison++ はありませんでした。

で、

>3
ftp://ftp.th-darmstadt.de/pub/programming/languages/C++/tools/flex++bison++/

でダウンロードしたのをコンパイルしようしたのですが、うまく
いかなかったもので。もうちょっとがんばってみます。

>4
flex c++ オプションとの違いはぼくも実際使ったことがないので
よくわかっていないのですが、おそらくきるクラスの使い方は
それほど違わないと思います。
ただ bison には c++ オプションが見当たらないので(必要ない?)
どうせなら両方 ++ を使ってみようと思ったのです。
先の ftp サイトにポストスクリプトのドキュメントがあります。
GSview で読めます。
http://www.c3.club.kyutech.ac.jp/c3mag2/SPECIAL/11/gs.html
0006名無しさん@1周年NGNG
byaccじゃないかな?>bison
00071(=5)NGNG
yacc のバークレー版が byacc@` GNU版が bison ということですよね?
cygwin には byacc と bison 両方はいってます。
00084NGNG
どうも 4です。1さん、ご教示ありがとうございます。
私も教えていただいた url からソース dl して遊んでみました。
Win32 用の bison++@` flex++ をお探しのようでしたので
VC++ で compile できるように makefile を適当になおしてみました。
すでにいらないかもしれませんね(^^; とりあえず
参考になる方がいらっしゃるかもしれない、ということで・・。
0009makefile of bison++ <1>NGNG
[Makefile] for bison++ 1.21-7
"nmake bison++" will make a some what of bison++.
---------------------------------------------------------------------------------
# Makefile for bison++ port of win32 console with VC++ command line tools
# Copyright (C) 1988@` 1989@` 1991@` 1993 Bob Corbett and Free Software Foundation@` Inc.
#
# This file is part of Bison@` the GNU Compiler Compiler.
#
# Bison 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 2@` or (at your option)
# any later version.
#
# Bison 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 Bison; see the file COPYING. If not@` write to
# the Free Software Foundation@` 675 Mass Ave@` Cambridge@` MA 02139@` USA.


#### Start of system configuration section. ####


# Things you might add to DEFS:
# -DSTDC_HEADERS If you have ANSI C headers and libraries.
# -DHAVE_STRING_H If you don't have ANSI C headers but have string.h.
# -DHAVE_MEMORY_H If you don't have ANSI C headers and have memory.h.
# -DHAVE_STRERROR If you have strerror function.
DEFS = /Dconst= /DHAVE_STRING_H=1 /DHAVE_STDLIB_H=1 /DHAVE_MEMORY_H=1 /DSTDC_HEADERS /D_MSDOS /D__GO32__


CC = cl
CFLAGS = /c /O2 /J
LDFLAGS =

LIBS = libc.lib

# Some System V machines do not come with libPW. If this is true@` use
# the GNU alloca.o here.
ALLOCA =


srcdir = .
VPATH = .
prefix = .
exec_prefix = $(prefix)

# where the installed binary goes
bindir = $(exec_prefix)\\bin

# where the parsers go
datadir = $(prefix)

## where the info files go
#infodir = $(ENV_DIR)/doc/info

## where manual pages go and what their extensions should be
#manext = 1
#mandir = $(ENV_DIR)/doc/man/man$(manext)

## dman documentation parser
#.SUFFIXES : .dman
#.dman :
# dman <$*.dman >$@
# pman -t $@ >$*.ps
#default : all
#
#backup :
# find . \( -name '*.o' -o -name '*%' -o -name 'bison++' -o -name '.#tar.excludes' \) -print >.tar.excludes
# tar cvfX - .tar.excludes . | compress -cv >../bison++.tar.Z

#### End of system configuration section. ####

0010makefile of bison++ <2>NGNG

# redefine make's built-in rule
.c.obj:
$(CC) $(CFLAGS) $(DEFS) $*.c


# names of parser files
PFILE = bison.cpp
PFILE1 = bison.hairy
HFILE = bison.h

PFILES = -DXPFILE=\"$(datadir)\\$(PFILE)\" -DXHFILE=\"$(datadir)\\$(HFILE)\" -DXPFILE1=\"$(datadir)\\$(PFILE1)\"

OBJECTS = lr0.obj allocate.obj closure.obj conflict.obj derives.obj files.obj getargs.obj gram.obj lalr.obj lex.obj main.obj nullable.obj output.obj print.obj reader.obj reduce.obj symtab.obj warshall.obj version.obj getopt.obj getopt1.obj $(ALLOCA)


bison++: $(OBJECTS)
link $(LDFLAGS) /SUBSYSTEM:CONSOLE /OUT:$*.exe $(OBJECTS) $(LIBS)


# This file is different to pass the parser file names to the compiler.
files.o: files.c
$(CC) -c $(PFILES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(srcdir)\\files.c $(OUTPUT_OPTION)


lr0.obj: system.h machine.h new.h gram.h state.h
closure.obj: system.h machine.h new.h gram.h
conflict.obj: system.h machine.h new.h files.h gram.h state.h
derives.obj: system.h new.h types.h gram.h
files.obj: system.h files.h new.h gram.h
getargs.obj: system.h files.h
lalr.obj: system.h machine.h types.h state.h new.h gram.h
lex.obj: system.h files.h symtab.h lex.h
main.obj: system.h machine.h
nullable.obj: system.h types.h gram.h new.h
output.obj: system.h machine.h new.h files.h gram.h state.h
print.obj: system.h machine.h new.h files.h gram.h state.h
reader.obj: system.h files.h new.h symtab.h lex.h gram.h
reduce.obj: system.h machine.h files.h new.h gram.h
symtab.obj: system.h new.h symtab.h gram.h
warshall.obj: system.h machine.h
0011makefile of flex++ <1>NGNG
[Makefile] for flex++ 2.3.8-6
"nmake flex++" will make a some what of flex++.
notice: prepare the bison for making it.
---------------------------------------------------------------------------------
# This makefile is used to port the flex 2.1 build to a PC. The compiler is
# Microsoft-C Version 5.0 while the 'make' utility came with Aztec-C@` which
# is VERY compatible with Unix's make. There are a few things that Aztec-C's
# 'make' can't do that unix does so I have made a few minor changes.
# At the least you can manually compile each file and then link.
# The linker and library utilities are alos Microsoft's.
#
# Additionally@` after building with the large model@` the flex.map reveals that
# code-size is less than 64K@` therefore@` in favor of a little more execution
# efficiency@` I built with the compact model. I've used the default compiler
# optimization (no /O switches).
#
# The linker must be told to increase the run-time stack space. The default
# stack space is 2048. Flexing scan.l with the default stack-space results in
# a run-time stack overflow@` hence the stack was increase to 4096.
#
# NOTE: I have MKS-Toolkit's yacc and was able to use it with virtually no
# modifications to anything. If you don't have yacc for a PC@` you can try
# yaccing on a unix system and downloading the resulting files to the PC.
#
# Jeffrey R. Jones
# jjones@angate!att.com


# make file for "flex" tool

# @(#) $Header: Makefile@`v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)

# Porting considerations:
#
# For System V Unix machines@` add -DSYS_V to CFLAGS.
# For Vax/VMS@` add -DSYS_V to CFLAGS.
# For MS-DOS@` add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present.
# You will also want to rename flex.skel to something with a three
# character extension@` change SKELETON_FILE below appropriately@`
# For Amiga@` add "-DAMIGA -DSYS_V" to CFLAGS.


# the first time around use "nmake first_flex++"


SKELETON_DIR = .
SKELETON_FILE = $(SKELETON_DIR)\\flexskel.cpp
HEADERSKELETON_FILE = $(SKELETON_DIR)\\flexskel.h
SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\" -DDEFAULT_SKELETONHEADER_FILE=\"$(HEADERSKELETON_FILE)\"

#this null definition prevents a returned error code
MFLAGS =

FLEX = flex++
FLEX_FLAGS = -ist8
YACC=bison
CC = cl
CFLAGS = /c /O2 /J -DSYS_V
LDFLAGS =

# redefine make's built-in rule
.c.obj:
$(CC) $(CFLAGS) $*.c
0012makefile of flex++ <2>NGNG
# break obj-list into two because of 128 character command-line limit of
# Microsoft's link and lib utilities.
FLEXOBJS1 = ccl.obj dfa.obj ecs.obj gen.obj main.obj misc.obj nfa.obj parse.obj
FLEXOBJS2 = scan.obj sym.obj tblcmp.obj yylex.obj

FLEX_C_SOURCES = \
ccl.c \
dfa.c \
ecs.c \
gen.c \
main.c \
misc.c \
nfa.c \
parse.c \
scan.c \
sym.c \
tblcmp.c \
yylex.c

# lib is used to get around the 128 character command-line limit of 'link'.
flex++.exe : $(FLEXOBJS1) $(FLEXOBJS2)
lib /OUT:tmplib.lib $(FLEXOBJS1)
link $(LDFLAGS) /SUBSYSTEM:CONSOLE /OUT:$*.exe $(FLEXOBJS2) tmplib.lib
del tmplib.lib

# the second 'make flex.exe' causes scan.l to be RE-flexed. The resulting
# scan.c is different from initscan.c in that \r\n are added instead of
# just \n. Since \r\n is DOS language and this is targetted for PCs@` and
# since I don't know what would happen for all cases in DOS-land@` I went
# ahead and did it.
first_flex++:
copy initscan.c scan.c
nmake $(MFLAGS) flex++.exe
del scan.c
nmake flex++.exe

parse.obj: parse.c parse.h

parse.h parse.c : parse.y
$(YACC) -d parse.y
ren parse.tab.c parse.c
ren parse.tab.h parse.h

scan.c : scan.l
$(FLEX) $(FLEX_FLAGS) scan.l > scan.c

scan.obj : scan.c parse.h

main.obj : main.c
$(CC) $(CFLAGS) $(SKELFLAGS) main.c

###################
#don't have@` or need@` anything else except maybe the 'test' rule.
#
# don't have nroff
#flex.man : flex.1
# nroff -man flex.1 >flex.man
#
# don't have lint
#lint : $(FLEX_C_SOURCES)
# lint $(FLEX_C_SOURCES) > flex.lint
#
#distrib :
# mv scan.c initscan.c
# chmod 444 initscan.c
# $(MAKE) $(MFLAGS) clean
#
#clean :
# rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags
#
#tags :
# ctags $(FLEX_C_SOURCES)
#
#vms : flex.man
# $(MAKE) $(MFLAGS) distrib
#
# break this up into multiple lines...Aztec 'make' limitation
test :
$(FLEX) $(FLEX_FLAGS) scan.l > scan.tst
fc scan.c scan.tst
del scan.tst
0013名無しさん@1周年NGNG
>4
うおーーー、ありがとう!!!
00141NGNG
>4
同じく、
うおーーー、ありがとう!!!
0015名無しさん@1周年NGNG
試してみたら
「makefile(77) : fatal error U1001: syntax error : 無効な文字 '*' がマクロ中にありま
す。
Stop.」
というエラーが出たのは私だけ?
00161NGNG
ぼくもでました。
<ターゲット>: の次の行の頭のタブがなくなってるので、それを
いれたらとおりました。たぶん掲示板に表示されるときになくなって
しまうのだと思います。
FLEX_C_SOURCE = \ の次のソースがたくさんならんでるところも
同様にタブを入れる必要があります。


あと flex++ で リンク時に alloca が未解決というエラーが
でますが、alloca ではなく、_alloca を使わないとだめなので
parse.c の頭のほうで例えば

#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS@` or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS@` __TURBOC__@` or _AIX */

/* 以下3行を追加
#if defined (WIN32)
#define alloca _alloca
#endif

#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS@` or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */

として、CFLAGS に /DWIN32 を追加してごまかしました。
00171NGNG
さっきの追加です。
FLEX_C_SOURCE = \ の次のソースがたくさんならんでるところ
の行末に余分なスペースが1つづつ入っているので削除して
ください。

実行すると bison++ では bison.cc bison.h がない
flex++ では flexskel.cc flexskel.h がないとおこられますので
カレントディレクトリにコピーするか、ソースでこれらのファイルを
記述しているところを grep して書き直せば大丈夫みたいです。

# /* 以下3行を追加 のコメントを閉じるの忘れました。
001815NGNG
>1
なるほど、どうもありがとうございます。
bison++は簡単にうまく行ったんだけど、flex++の方が
うまく行かない…
0019名無しさん@1周年NGNG
例えば
flex++.exe : $(FLEXOBJS1) $(FLEXOBJS2)
の次の行なんか3行に渡って頭にタブ入れないとだめですよ。

first_flex++ :
parse.h parse.c : parse.y
test :
の次とかも複数行にいれないといけないところがあります。
002015NGNG
>19
うまく行きました…
tabを入れてないところがありました。
なんか色々とファイルを手動でリネームして出来たんだけど
いいのかな…(^^;;
0021名無しさん@1周年NGNG
ところで、flexやBisonで生成したコードのライセンスは
どうなっているのだろう?
このコードの全体の著作権を自分が主張しても良いのでしょうか?
また、このコードは自由に使っちゃって良いのだろうか?
GPLのように、フリーソフトウェアにしか使えないとか、そういう
何か義務が発生したりしないでしょうか?
0022>21NGNG
>GPLのように、フリーソフトウェアにしか使えないとか
いつからGPLがフリーソフトにしか使えなくなったんだ?
日本語訳があるんだからきちんと読め
0023名無しさん@1周年NGNG
GPLが適用されたソースコードを使用した場合、
そのソフトにはGPLが適用されなくてはなりませんよね?
0024名無しさん@1周年NGNG
生成したコードは関係ないよ。
Word で作った野球部のポスターは MS に著作権があるわけじゃないでしょ
0025名無しさん@1周年NGNG
だからといってフリーソフトである必要はない
002625NGNG
>23
0027名無しさん@1周年NGNG
GPLなのにフリーソフトじゃないってどういうこと?
確かに商用アプリとかにして、お金を取っても良いのかもしれないけど、
ソースは公開しなくちゃいけないし、そういう意味ではフリーソフトウェアでは?
0028名無しさん@1周年NGNG
GNUのbison@`flex関係の著作権は特別に他のGNUのとはちがうライセンスが用意してあったよ〜
やっぱワードで作ったポスターよりは権利関係が複雑みたい
00294NGNG
こんばんは 4 です。適当にやっちゃったのでご迷惑おかけしてます。
タブが飛んじゃって申し訳ないです。 zip->MIME にしておけばよかった。(^^;)
flex++ は bison の生成するコードが alloca を使うバージョンなので
発生してますね。bison.hairy あたりに修正が必要です。(^^;)
nmake first_flex++ だったり /J や /DHAVE_STRING_H=1 や /DHAVE_MEMORY_H=1
がやばそうだったり、flex の OBJ は分ける必要がなかったり、なんとかしてください。(ぉぃぉぃ^^;)
0030名無しさん@1周年NGNG
GPLでのフリーの意味を履き違えてる奴が何人か生息してるな(わ
0031名無しさん@1周年NGNG
>28
それ詳しく解説したページや書籍は無いですかね?
>30
何番の奴が間違ってる?
0032名無しさん@1周年NGNG
/* As a special exception@` when this file is copied by Bison into a
Bison output file@` you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */

bison1.24の骸骨ファイルの一文です。制限なく(without restriction) ってあるけど
bison の生成物は自由に (商用でも) 使っていいよ、ってことなのかな?
0033名無しさん@1周年NGNG
多分、bisonの生成物の中にはFSFが作ったコードが一部含まれますよね?
もしそうだとしたら、生成物の著作権はどうなるんでしょう?
003432NGNG
use にのみ限定して without restriction 。
使用に限って制限なくて、著作権は FSF が持ってるんじゃないですか?
作ったのは FSF だし。(憶測)

別のこと。
あと、構文の制作者の著作権なんて言われると困りそう。
そこまで主張すると別でやれって言いそうだけど(bison じゃなくて)。

うーん、でもつっこんで考えると FSF に直接聞くかページ探すしかないような
いい解説のページないですかね?
003532NGNG
>別でやれ
あ・・べつの著作権で主張して、っていうことで、
bison に持ち込まないことという意味です・・。
003630>31NGNG
GPLでのフリーの意味を知ってるなら言わなくても分かるはずだが。
0037名無しさん@1周年NGNG
>36
GPLでのフリーの意味って何?
いや、日本語訳読もうとしたんだけど、難解なんで挫折しちゃって…
■ このスレッドは過去ログ倉庫に格納されています