Package analyzer

Examples of analyzer.SyntaxTree


  public static void main( String args[] ){
   
    LexiconAnalyzer lexicon = new LexiconAnalyzer( "codigo.tny" );
    SyntacticAnalyzer syntactic = new SyntacticAnalyzer( lexicon.analyze() );
    SyntaxTree tree = syntactic.analyze();
    TableBuilder builder = new TableBuilder( tree );
    CodeGenerator generator = new CodeGenerator( tree, builder.build() );
   
    generator.generate( "codigo.tm" );
  }
View Full Code Here


  /*
   * producao de uma sequencia de declaracoes
   */
  private SyntaxTree statementSequence(){
   
    SyntaxTree node = this.statement();
    SyntaxTree node2 = node;
    TokenType.Element type = this.currentToken.getType();
   
    while( type != TokenType.Element.NONE && type != TokenType.Element.END && type != TokenType.Element.ELSE && type != TokenType.Element.UNTIL ){
     
      SyntaxTree node3 = null;
      this.match( TokenType.Element.INSTRUCTION_END );
      node3 = this.statement();
     
      if( node3 != null ){
       
View Full Code Here

  /*
   * producao de uma declaracao
   */
  private SyntaxTree statement(){
   
    SyntaxTree node = null;
   
    switch( this.currentToken.getType() ){
   
      case IF:
        node = this.statementIf();
View Full Code Here

  /*
   * producao de uma declaracao IF
   */
  private SyntaxTree statementIf(){
   
    SyntaxTree node = new SyntaxTree( SyntaxType.Tree.STATEMENT, SyntaxType.StatementKind.IF, this.currentToken );
   
    this.match( TokenType.Element.IF );
    node.appendChild( this.expression() );
   
    this.match( TokenType.Element.THEN );
    node.appendChild( this.statementSequence() );
   
    if( this.currentToken.getType() == TokenType.Element.ELSE ){
     
      this.match( TokenType.Element.ELSE );
      node.appendChild( this.statementSequence() );
    }
   
    this.match( TokenType.Element.END );
    return node;
  }
View Full Code Here

  /*
   * producao de uma declaracao REPEAT
   */
  private SyntaxTree statementRepeat(){
   
    SyntaxTree node = new SyntaxTree( SyntaxType.Tree.STATEMENT, SyntaxType.StatementKind.REPEAT, this.currentToken );
   
    this.match( TokenType.Element.REPEAT );
    node.appendChild( this.statementSequence() );
   
    this.match( TokenType.Element.UNTIL );
    node.appendChild( this.expression() );
   
    return node;
  }
View Full Code Here

  /*
   * producao de uma declaracao de atribuicao
   */
  private SyntaxTree statementAttribution(){
   
    SyntaxTree node = new SyntaxTree( SyntaxType.Tree.STATEMENT, SyntaxType.StatementKind.ATTRIBUTION, this.currentToken );
   
    this.match( TokenType.Element.IDENTIFIER );   
    this.match( TokenType.Element.ATTRIBUTION );
    node.appendChild( this.expression() );
   
    return node;
  }
View Full Code Here

   * producao de uma declaracao READ
   */
  private SyntaxTree statementRead(){
   
    this.match( TokenType.Element.READ );
    SyntaxTree node = new SyntaxTree( SyntaxType.Tree.STATEMENT, SyntaxType.StatementKind.READ, this.currentToken );
    this.match( TokenType.Element.IDENTIFIER );
   
    return node;
  }
View Full Code Here

  /*
   * producao de uma declaracao WRITE
   */
  private SyntaxTree statementWrite(){
   
    SyntaxTree node = new SyntaxTree( SyntaxType.Tree.STATEMENT, SyntaxType.StatementKind.WRITE, this.currentToken );
   
    this.match( TokenType.Element.WRITE );
    node.appendChild( this.expression() );
   
    return node;
  }
View Full Code Here

  /*
   * producao de uma expressao
   */
  private SyntaxTree expression(){
   
    SyntaxTree node = this.simpleExpression();
    TokenType.Element type = this.currentToken.getType();
   
    while( type == TokenType.Element.LESS_THAN || type == TokenType.Element.EQUALS ){
     
      SyntaxTree child = new SyntaxTree( SyntaxType.Tree.EXPRESSION, SyntaxType.ExpressionKind.OPERATION, this.currentToken );
      child.appendChild( node );
      node = child;
      this.match( type );
      node.appendChild( this.simpleExpression() );
     
      type = this.currentToken.getType();
View Full Code Here

  /*
   * producao de uma expressao simples
   */
  private SyntaxTree simpleExpression(){
   
    SyntaxTree node = this.term();
    TokenType.Element type = this.currentToken.getType();
   
    while( type == TokenType.Element.PLUS || type == TokenType.Element.MINUS ){
     
      SyntaxTree child = new SyntaxTree( SyntaxType.Tree.EXPRESSION, SyntaxType.ExpressionKind.OPERATION, this.currentToken );
      child.appendChild( node );
      node = child;
      this.match( type );
      node.appendChild( this.term() );
     
      type = this.currentToken.getType();
View Full Code Here

TOP

Related Classes of analyzer.SyntaxTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.