basic.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/while/basic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/while/basic.carbon
  10. fn F() {
  11. while (a) {
  12. if (b) {
  13. break;
  14. }
  15. if (c) {
  16. continue;
  17. }
  18. }
  19. }
  20. // CHECK:STDOUT: - filename: basic.carbon
  21. // CHECK:STDOUT: parse_tree: [
  22. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  23. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  24. // CHECK:STDOUT: {kind: 'IdentifierNameMaybeBeforeSignature', text: 'F'},
  25. // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
  26. // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2},
  27. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  28. // CHECK:STDOUT: {kind: 'WhileConditionStart', text: '('},
  29. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
  30. // CHECK:STDOUT: {kind: 'WhileCondition', text: ')', subtree_size: 3},
  31. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  32. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  33. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
  34. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  35. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  36. // CHECK:STDOUT: {kind: 'BreakStatementStart', text: 'break'},
  37. // CHECK:STDOUT: {kind: 'BreakStatement', text: ';', subtree_size: 2},
  38. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 4},
  39. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  40. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  41. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'c'},
  42. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  43. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  44. // CHECK:STDOUT: {kind: 'ContinueStatementStart', text: 'continue'},
  45. // CHECK:STDOUT: {kind: 'ContinueStatement', text: ';', subtree_size: 2},
  46. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 4},
  47. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  48. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 18},
  49. // CHECK:STDOUT: {kind: 'WhileStatement', text: 'while', subtree_size: 22},
  50. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 28},
  51. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  52. // CHECK:STDOUT: ]