ApiLexer.g4 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. lexer grammar ApiLexer;
  2. // Keywords
  3. ATDOC: '@doc';
  4. ATHANDLER: '@handler';
  5. INTERFACE: 'interface{}';
  6. ATSERVER: '@server';
  7. // Whitespace and comments
  8. WS: [ \t\r\n\u000C]+ -> channel(HIDDEN);
  9. COMMENT: '/*' .*? '*/' -> channel(88);
  10. LINE_COMMENT: '//' ~[\r\n]* -> channel(88);
  11. STRING: '"' (~["\\] | EscapeSequence)* '"';
  12. RAW_STRING: '`' (~[`\\\r\n] | EscapeSequence)+ '`';
  13. LINE_VALUE: ':' [ \t]* (STRING|(~[\r\n"`]*));
  14. ID: Letter LetterOrDigit*;
  15. fragment ExponentPart
  16. : [eE] [+-]? Digits
  17. ;
  18. fragment EscapeSequence
  19. : '\\' [btnfr"'\\]
  20. | '\\' ([0-3]? [0-7])? [0-7]
  21. | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
  22. ;
  23. fragment HexDigits
  24. : HexDigit ((HexDigit | '_')* HexDigit)?
  25. ;
  26. fragment HexDigit
  27. : [0-9a-fA-F]
  28. ;
  29. fragment Digits
  30. : [0-9] ([0-9_]* [0-9])?
  31. ;
  32. fragment LetterOrDigit
  33. : Letter
  34. | [0-9]
  35. ;
  36. fragment Letter
  37. : [a-zA-Z$_] // these are the "java letters" below 0x7F
  38. | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
  39. | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
  40. ;