Lemon parser as Xcode build rule

放肆的年华 提交于 2019-12-13 13:42:12

问题


When using lemon parser in Xcode integrated as 'Yacc source file using Script', warnings generated by lemon don't show up in the Xcode warning section.


回答1:


The lemon warning output is not compatible with the format expected by Xcode. Lemon output is formatted like this:

filename.y:NR: message

Note: Lemon also seems to limit the filename to 20 characters in its warning output.

While Xcode expects:

path:NR: warning: message

This can be done with awk lemon $INPUT_FILE_BASE.y | awk -F ': ' -v base="${BASE}" '{ print base "/" $1 ": warning: " $2}'

Here my complete script:

LEMON=$(printf %q "$BUILT_PRODUCTS_DIR/lemon")
LEMPAR=$(printf %q "$SRCROOT/../Vendor/lemon/lempar.c")
BASE=$(dirname "$INPUT_FILE_PATH.y")

cd $DERIVED_FILES_DIR
cp $INPUT_FILE_PATH $INPUT_FILE_BASE.y
cp $LEMPAR $DERIVED_FILES_DIR/lempar.c
$LEMON $INPUT_FILE_BASE.y | awk -F ': ' -v base="${BASE}" '{ print base "/" $1 ": warning: " $2}'

mv $INPUT_FILE_BASE.c $INPUT_FILE_BASE.m

Xcode 'Yacc source file using Script':

Warnings are also shown inline in the gramma file now:



来源:https://stackoverflow.com/questions/54803221/lemon-parser-as-xcode-build-rule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!