3

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.

catlan
  • 25,100
  • 8
  • 67
  • 78
  • Aren't the warnings written to stdout and therefore viewable from the Xcode build tab? – trojanfoe Feb 21 '19 at 09:28
  • They are viewable in the report navigator, but you need to navigate there, filter for the filename... The build log is very noisy. Very easy to overlook or forget. With the fix below the warning are also shown inline in the gramma file. – catlan Feb 21 '19 at 09:37
  • OK cool. Thanks for the info. – trojanfoe Feb 21 '19 at 09:37

1 Answers1

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': Xcode Yacc source file using Script

Warnings are also shown inline in the gramma file now: Warning : This rule can not be reduced.

catlan
  • 25,100
  • 8
  • 67
  • 78