Skip to content

Instantly share code, notes, and snippets.

@suin
Created February 3, 2012 13:41
Show Gist options
  • Save suin/1730216 to your computer and use it in GitHub Desktop.
Save suin/1730216 to your computer and use it in GitHub Desktop.
kmyaccとPHPでオレオレプログラミング言語を作る - 環境構築編 ref: http://qiita.com/items/2011
$ git clone https://github.com/moriyoshi/kmyacc-forked.git
Cloning into kmyacc-forked...
remote: Counting objects: 76, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 76 (delta 14), reused 76 (delta 14)
Unpacking objects: 100% (76/76), done.
$ cd kmyacc-forked/
$ /usr/bin/php sample/calc.php
1+2+3
6
^C
$ vim src/Makefile
PREFIX = /usr/local を
PREFIX = /Users/suin に書き換える
$ mkdir ~/bin ~/lib
$ echo $PATH
/Users/suin/bin:/Applications/MAMP/bin/php5.2/bin:/Applications/MAMP/Library/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
$ make
cd src; make all
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o yacc.o yacc.c
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o grammar.o grammar.c
grammar.c: In function ‘intern’:
grammar.c:106: warning: cast from pointer to integer of different size
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o token.o token.c
token.c: In function ‘raw_gettoken’:
token.c:331: warning: control reaches end of non-void function
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o lalr.o lalr.c
lalr.c: In function ‘cmpprec’:
lalr.c:707: warning: control reaches end of non-void function
lalr.c: In function ‘item2pnum’:
lalr.c:170: warning: control reaches end of non-void function
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o misc.o misc.c
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o genparser.o genparser.c
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' -c -o compress.o compress.c
cc -Wall -O2 '-DPARSERBASE="/Users/suin/lib/kmyacc"' yacc.o grammar.o token.o lalr.o misc.o genparser.o compress.o -o kmyacc
$ make install
cd src; make install
install -d /Users/suin/bin
install -s kmyacc /Users/suin/bin
install -d /Users/suin/lib
install -d /Users/suin/lib/kmyacc
install kmyacc.c.parser /Users/suin/lib/kmyacc
install kmyacc.java.parser /Users/suin/lib/kmyacc
install kmyacc.js.parser /Users/suin/lib/kmyacc
install kmyacc.pl.parser /Users/suin/lib/kmyacc
install kmyacc.py.parser /Users/suin/lib/kmyacc
install kmyacc.php.parser /Users/suin/lib/kmyacc
install kmyacc.as.parser /Users/suin/lib/kmyacc
install kmyacc.hsp.parser /Users/suin/lib/kmyacc
$ kmyacc
KMyacc - parser generator ver 4.1.4
Copyright (C) 1987-1989,1992-1993,2005,2006 MORI Koichiro
Usage: kmyacc [-dvltani] [-b y] [-p yy] [-m model] [-L lang] grammar.y
$ kmyacc -m ~/lib/kmyacc/kmyacc.php.parser sample/calc.phpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment