Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. grammar Chat;
  2.  
  3. /*
  4. * Parser Rules
  5. */
  6.  
  7. chat : line+ EOF ;
  8.  
  9. line : name command message NEWLINE ;
  10.  
  11. message : (emoticon | link | color | mention | WORD | WHITESPACE)+ ;
  12.  
  13. name : WORD WHITESPACE;
  14.  
  15. command : (SAYS | SHOUTS) ':' WHITESPACE ;
  16.  
  17. emoticon : ':' '-'? ')'
  18. | ':' '-'? '('
  19. ;
  20.  
  21. link : TEXT TEXT ;
  22.  
  23. color : '/' WORD '/' message '/';
  24.  
  25. mention : '@' WORD ;
  26.  
  27.  
  28. /*
  29. * Lexer Rules
  30. */
  31.  
  32. fragment A : ('A'|'a') ;
  33. fragment S : ('S'|'s') ;
  34. fragment Y : ('Y'|'y') ;
  35. fragment H : ('H'|'h') ;
  36. fragment O : ('O'|'o') ;
  37. fragment U : ('U'|'u') ;
  38. fragment T : ('T'|'t') ;
  39.  
  40. fragment LOWERCASE : [a-z] ;
  41. fragment UPPERCASE : [A-Z] ;
  42.  
  43. SAYS : S A Y S ;
  44.  
  45. SHOUTS : S H O U T S ;
  46.  
  47. WORD : (LOWERCASE | UPPERCASE | '_')+ ;
  48.  
  49. WHITESPACE : (' ' | '\t')+ ;
  50.  
  51. NEWLINE : ('\r'? '\n' | '\r')+ ;
  52.  
  53. TEXT : ('['|'(') .*? (']'|')');
  54. © 2019 GitHub, Inc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement