keywords.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/lex/testdata/keywords.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lex/testdata/keywords.carbon
  10. // --- indented.carbon
  11. // CHECK:STDOUT: - filename: indented.carbon
  12. // CHECK:STDOUT: tokens: [
  13. // CHECK:STDOUT: { index: 0, kind: 'FileStart', line: {{ *\d+}}, column: 1, indent: 1, spelling: '' },
  14. fn
  15. // CHECK:STDOUT: { index: 1, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 4, indent: 4, spelling: 'fn', has_leading_space: true },
  16. // CHECK:STDOUT: { index: 2, kind: 'FileEnd', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '', has_leading_space: true },
  17. // CHECK:STDOUT: ]
  18. // --- chain.carbon
  19. // CHECK:STDOUT: - filename: chain.carbon
  20. // CHECK:STDOUT: tokens: [
  21. // CHECK:STDOUT: { index: 0, kind: 'FileStart', line: {{ *\d+}}, column: 1, indent: 1, spelling: '' },
  22. and or not if else for return var break continue _
  23. // CHECK:STDOUT: { index: 1, kind: 'And', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'and', has_leading_space: true },
  24. // CHECK:STDOUT: { index: 2, kind: 'Or', line: {{ *}}[[@LINE-2]], column: 5, indent: 1, spelling: 'or', has_leading_space: true },
  25. // CHECK:STDOUT: { index: 3, kind: 'Not', line: {{ *}}[[@LINE-3]], column: 8, indent: 1, spelling: 'not', has_leading_space: true },
  26. // CHECK:STDOUT: { index: 4, kind: 'If', line: {{ *}}[[@LINE-4]], column: 12, indent: 1, spelling: 'if', has_leading_space: true },
  27. // CHECK:STDOUT: { index: 5, kind: 'Else', line: {{ *}}[[@LINE-5]], column: 15, indent: 1, spelling: 'else', has_leading_space: true },
  28. // CHECK:STDOUT: { index: 6, kind: 'For', line: {{ *}}[[@LINE-6]], column: 20, indent: 1, spelling: 'for', has_leading_space: true },
  29. // CHECK:STDOUT: { index: 7, kind: 'Return', line: {{ *}}[[@LINE-7]], column: 24, indent: 1, spelling: 'return', has_leading_space: true },
  30. // CHECK:STDOUT: { index: 8, kind: 'Var', line: {{ *}}[[@LINE-8]], column: 31, indent: 1, spelling: 'var', has_leading_space: true },
  31. // CHECK:STDOUT: { index: 9, kind: 'Break', line: {{ *}}[[@LINE-9]], column: 35, indent: 1, spelling: 'break', has_leading_space: true },
  32. // CHECK:STDOUT: { index: 10, kind: 'Continue', line: {{ *}}[[@LINE-10]], column: 41, indent: 1, spelling: 'continue', has_leading_space: true },
  33. // CHECK:STDOUT: { index: 11, kind: 'Underscore', line: {{ *}}[[@LINE-11]], column: 50, indent: 1, spelling: '_', has_leading_space: true },
  34. // CHECK:STDOUT: { index: 12, kind: 'FileEnd', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '', has_leading_space: true },
  35. // CHECK:STDOUT: ]
  36. // --- notakeyword.carbon
  37. // CHECK:STDOUT: - filename: notakeyword.carbon
  38. // CHECK:STDOUT: tokens: [
  39. // CHECK:STDOUT: { index: 0, kind: 'FileStart', line: {{ *\d+}}, column: 1, indent: 1, spelling: '' },
  40. notakeyword
  41. // CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'notakeyword', identifier: 0, has_leading_space: true },
  42. // CHECK:STDOUT: { index: 2, kind: 'FileEnd', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '', has_leading_space: true },
  43. // CHECK:STDOUT: ]