Reputation: 191209
Running Swig example for ocaml gives me this error message.
rm -rf swig.mli swig.ml swigp4.ml && ../../../preinst-swig -ocaml -co swig.mli 2>/dev/null && ../../../preinst-swig -ocaml -co swig.ml 2>/dev/null && ../../../preinst-swig -ocaml -co swigp4.ml 2>/dev/null && ocamlc -c swig.mli && ocamlc -c swig.ml && ocamlc -I ` camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml File "swig.ml", line 159, characters 54-57: Warning 20: this argument will not be used by the function. File "swigp4.ml", line 26, characters 2-6: Parse error: Deprecated syntax, the grammar module is expected File "swigp4.ml", line 1, characters 0-1: Error: Preprocessor error
The File "swigp4.ml", line 26, characters 2-6 has the following content.
EXTEND Line 25: expr: Line 26: [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> Line 27: > ... Line 114: | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> Line 115: > Line 116: ] ] ; Line 117: END ;;
What might be wrong? How to install grammar module with ocaml?
I use Mac OS X 10.6.4, and I installed Ocaml from this site.
And I got the following result with 'camlp4 -where'.
simple> camlp4 -where /usr/local/lib/ocaml/camlp4
The swigp4.ml is downloadable here.
Upvotes: 1
Views: 634
Reputation: 23707
I believe you're not using the latest version of Swig. With Swig 1.3 I had the same issue. Try moving to swig 2.0.X and you'll have no issues.
I've been working on ocaml bindings for Xapian and unfortunately the ocaml support in Swig has gone a bit unmaintained. However, I've found the examples in the Swig source tree to be extremely helpful. I've put together a decent make recipe for compiling the swig dependencies. You'll probably notice this is not really any different than the swig examples, I am just shamelessly using this time to share it:
SWIG=../../swig/preinst-swig
swig:
$(SWIG) -ocaml -co swigp4.ml
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
ocamlfind ocamlc -package camlp4 \
-pp "camlp4o pa_extend.cmo q_MLast.cmo" \
-c swigp4.ml
ocamlc -c swig.mli swig.ml
You can then build with that by including a -pp "camlp4o ./swig4.cmo"
when compiling any code that uses the syntax extensions. You will also need to add swig.cmo
when linking. I've got a gist of my complete Makefile which you might also find useful.
Upvotes: 0
Reputation: 47954
I've never used this swig package, but have used the camlp4 grammar module. You probably have camlp4, so I'm guessing the issue is the syntax being used. You can check for camlp4 and the grammar module, find the camlp4 directory by,camlp4 -where
and see if that directory has, /Camlp4Parsers/Camlp4GrammarParser.[cmi|cmo|cmx|o]
If it's the syntax, I pulled up some code for a camlp4 grammar, and the expressions are structured slightly differently (I'm unsure if that format is invalid or not, but it's at least not how I've structured it before)
[[ | expr1 | expr2 ]]
should be
[ [ expr1] | [expr2] ]
Upvotes: 1