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

Dart implementation of the YES scriplet standard. YES is a meta scriptlet standard whose elements and meaning are customized by the programmer. This library parses files using the YES spec and deliver [...]

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 File file = File.fromUri(Uri.file("example/example.mesh"));

  final p = YesParser.fromFile(
    file,
    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
76
downloads

Publisher

unverified uploader

Weekly Downloads

Dart implementation of the YES scriplet standard. YES is a meta scriptlet standard whose elements and meaning are customized by the programmer. This library parses files using the YES spec and delivers the result as elements. Use the KeyVal args passed into each element to provide external functionality to their own software easily and quickly at no cost to readability or flexibility. It is a format for everyone.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on yes_parser