Add negative parsing tests using mlir-opt.

Add parsing tests with errors. Follows direct path of splitting file into test groups (using a marker) and parsing each section individually. The expected errors are checked using FileCheck and parser error does not result in terminating parsing the rest of the file if check-parser-error.

This is an interim approach until refactoring lexer/parser.

PiperOrigin-RevId: 201867941
diff --git a/test/IR/parser-errors.mlir b/test/IR/parser-errors.mlir
new file mode 100644
index 0000000..288222b
--- /dev/null
+++ b/test/IR/parser-errors.mlir
@@ -0,0 +1,23 @@
+; TODO(andydavis) Resolve relative path issue w.r.t invoking mlir-opt in RUN
+; statements (perhaps through using lit config substitutions).
+;
+; RUN: %S/../../mlir-opt %s -o - -check-parser-errors 2>&1 | FileCheck %s
+
+; Check different error cases.
+; TODO(jpienaar): This is checking the errors by simplify verifying the output.
+; -----
+; CHECK: expected type
+; CHECK-NEXT: illegaltype
+extfunc @illegaltype(i42)
+; -----
+; CHECK: expected type
+; CHECK-NEXT: nestedtensor
+extfunc @nestedtensor(tensor<tensor<i8>>) -> ()
+; -----
+; CHECK: expected '{' in CFG function
+cfgfunc @foo()
+cfgfunc @bar()
+; -----
+; CHECK: expected a function identifier like
+; CHECK-NEXT: missingsigil
+extfunc missingsigil() -> (i1, int, f32)