Advertisement
Guest User

Untitled

a guest
Feb 1st, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. expr : expr[ var_name ] '+' ident[ other_var_name ] ( some_action(var_name, other_var_name)) | ident[ third_var ] (some_other_action(third_var))
  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. T t;
  15. switch(current_token->type) {
  16. case ident:
  17. auto internal_var = ShiftIdent();
  18. while(true) {
  19. switch(current_token->type) {
  20. case '+':
  21. ShiftPlus();
  22. switch(current_token->type) {
  23. case ident:
  24. auto&& other_var_name = ShiftIdent();
  25. {
  26. auto&& other_var_name = internal_var;
  27. auto&& var_name = t;
  28. t = some_action(var_name, other_var_name));
  29. };
  30. break;
  31. default:
  32. error();
  33. }
  34. break;
  35. default:
  36. {
  37. auto&& third_var = internal_var;
  38. return some_other_action(third_var);
  39. }
  40. };
  41. }
  42. break;
  43. default:
  44. error();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement