Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
Ignore comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thosakwe committed Aug 2, 2018
1 parent 659a124 commit 2691ecf
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 37 deletions.
6 changes: 0 additions & 6 deletions .idea/runConfigurations/All_Tests.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/runConfigurations/tests_in_comment_test_dart.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/tests_in_graphql_parser.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .travis.yml
@@ -1,3 +1,6 @@
language: dart
dart:
- dev
- stable
script:
- travis.sh
- bash -ex travis.sh
3 changes: 2 additions & 1 deletion graphql_parser/lib/src/language/lexer.dart
Expand Up @@ -3,6 +3,7 @@ import 'syntax_error.dart';
import 'token.dart';
import 'token_type.dart';

final RegExp _comment = RegExp(r'#[^\n]*');
final RegExp _whitespace = new RegExp('[ \t\n\r]+');
final RegExp _boolean = new RegExp(r'true|false');
final RegExp _number = new RegExp(r'-?[0-9]+(\.[0-9]+)?(E|e(\+|-)?[0-9]+)?');
Expand Down Expand Up @@ -41,7 +42,7 @@ List<Token> scan(String text) {
while (!scanner.isDone) {
List<Token> potential = [];

if (scanner.scan(_whitespace)) continue;
if (scanner.scan(_comment) || scanner.scan(_whitespace)) continue;

for (var pattern in _patterns.keys) {
if (scanner.matches(pattern)) {
Expand Down
26 changes: 0 additions & 26 deletions graphql_parser/test/all.dart

This file was deleted.

16 changes: 16 additions & 0 deletions graphql_parser/test/comment_test.dart
@@ -0,0 +1,16 @@
import 'package:graphql_parser/graphql_parser.dart';
import 'package:test/test.dart';

void main() {
test('heeds comments', () {
var tokens = scan('''
# Hello
{
# Goodbye
}
# Bonjour
''');

expect(tokens, hasLength(2));
});
}
2 changes: 0 additions & 2 deletions travis.sh
@@ -1,4 +1,2 @@
#!/usr/bin/env bash
set -e
set -x
cd graphql_parser && pub get && pub run test -j2 && cd..

0 comments on commit 2691ecf

Please sign in to comment.