Advertisement
Guest User

Untitled

a guest
Feb 1st, 2012
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None
  1. expr : expr '+' ident | ident
  2.  
  3. std::wstring ShiftIdent() {
  4. auto ident = current_token->codepoints; // for example
  5. current_token++;
  6. return ident;
  7. }
  8.  
  9. void ShiftPlus() {
  10. current_token++;
  11. }
  12.  
  13. T ShiftExpr() {
  14. switch(current_token->type) {
  15. case ident:
  16. ShiftIdent();
  17. break;
  18. default:
  19. error();
  20. }
  21. while(true) {
  22. switch(current_token->type) {
  23. case '+':
  24. ShiftPlus();
  25. auto some_var = ShiftIdent();
  26. break;
  27. default:
  28. auto action = [&] () -> T {
  29. // somestuff, which can use some_var
  30. };
  31. return action();
  32. };
  33. }
  34. }
Advertisement
RAW Paste Data Copied
Advertisement