Created
          November 14, 2009 21:56 
        
      - 
      
- 
        Save anonymous/234804 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | void Operand() | |
| { | |
| if(matches(TokenId.Identifier, TokenId.LiteralValue)) | |
| { | |
| match(TokenId.Identifier, TokenId.LiteralValue); | |
| } | |
| else | |
| Expr(); | |
| } | |
| void Expr() | |
| { | |
| match(TokenId.Plus, TokenId.Minus, ...); | |
| Operand(); | |
| Operand(); | |
| } | |
| // "matches" should verify that the lookahead is one of the list provided | |
| // as its argument. If it is, it should return true. otherwise false. | |
| // "match" should verify that the lookahead is one of the list provided | |
| // as its argument. It should consume the token if it matches, and set | |
| // the lookahead to the next token from the string. If it doesn't match | |
| // it should throw and give a message that the parse failed while expecting | |
| // one of the tokens passed as the argument (in a normal parser). | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment