yes_parser 1.0.0 copy "yes_parser: ^1.0.0" to clipboard
yes_parser: ^1.0.0 copied to clipboard

Dart implementation of the YES scriplet standard

example/yes_parser_example.dart

import 'dart:io';
import 'package:yes_parser/yes_parser.dart';

/// This example demonstrates how to parse a file using the YES spec
/// And how to report errors after parsing.

void main() async {
  final p = YesParser.fromFile(File.fromUri(Uri.file("example/example.mesh")))
    ..onComplete(printAll);

  // Wait for parser to finish before ending program
  await p.join();
}

void printAll(List<ElementInfo> elements, List<ErrorInfo> errors) {
  // Print every element
  for (final info in elements) {
    final Element el = info.element;
    // Print every attribute this standard element has
    if (el.isStandard) {
      for (final attr in (el as Standard).attrs) {
        print(attr);
      }
    }
    print(el);
  }

  // Print errors with line numbers, if any
  for (final e in errors) {
    // Do not report empty lines (new lines)
    if (e.type == ErrorType.eolNoData) continue;

    print('Error: $e');
  }
}
2
likes
0
points
65
downloads

Publisher

unverified uploader

Weekly Downloads

Dart implementation of the YES scriplet standard

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on yes_parser