nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: UTF-8 Regex
[nit.git]
/
contrib
/
objcwrapper
/
src
/
objcwrapper.nit
diff --git
a/contrib/objcwrapper/src/objcwrapper.nit
b/contrib/objcwrapper/src/objcwrapper.nit
index
b1abbc6
..
28746d8
100644
(file)
--- a/
contrib/objcwrapper/src/objcwrapper.nit
+++ b/
contrib/objcwrapper/src/objcwrapper.nit
@@
-23,15
+23,18
@@
import objc_model
import objc_generator
import objc_lexer
import objc_parser
import objc_generator
import objc_lexer
import objc_parser
+import preprocessing
var opt_help = new OptionBool("Show this help message", "-h", "--help")
var opts = new OptionContext
var opt_help = new OptionBool("Show this help message", "-h", "--help")
var opts = new OptionContext
-opts.add_option(opt_help, opt_output)
-opts.parse(args)
+opts.add_option(opt_help, opt_output, opt_init_as_methods, opt_gcc_options)
+opts.parse args
if opts.errors.not_empty or opts.rest.is_empty or opt_help.value then
if opts.errors.not_empty or opts.rest.is_empty or opt_help.value then
- print """
+ if opts.errors.not_empty then print_error opts.errors.join("\n")
+
+ print_error """
Usage: objcwrapper [options] input_file [other_input_file [...]]
Options:"""
opts.usage
Usage: objcwrapper [options] input_file [other_input_file [...]]
Options:"""
opts.usage
@@
-41,11
+44,11
@@
Options:"""
end
var v = new ObjcVisitor
end
var v = new ObjcVisitor
-var g = new CodeGenerator
-for arg in opts.rest do
+var failed_parsing = new Array[String]
+for src in opts.rest do
# Read input
# Read input
- var content = arg.to_path.read_all
+ var content = src.preprocess_content
# Parse
var lexer = new Lexer_objc(content)
# Parse
var lexer = new Lexer_objc(content)
@@
-56,7
+59,11
@@
for arg in opts.rest do
# Check for errors
if root isa NError then
# Check for errors
if root isa NError then
- print_error "Syntax Error: {root.message}: {root.position or else ""}"
+ var pos = root.position
+ print_error "Syntax Error: {root.message}, at {pos or else ""}"
+ print_error "in {src}"
+ if pos != null then print_error pos.underline(content)
+ failed_parsing.add src
continue
end
continue
end
@@
-64,4
+71,10
@@
for arg in opts.rest do
v.enter_visit root
end
v.enter_visit root
end
-g.generate v.model.classes
+var g = new CodeGenerator(v.model)
+g.generate
+
+if failed_parsing.not_empty then
+ print_error "Failed to parse {failed_parsing.length}/{opts.rest.length} files:"
+ print_error failed_parsing.join(" ")
+end