Skip to content

Commit

Permalink
syntax.y tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Mellywins committed Mar 17, 2022
1 parent 056acc5 commit 73b4315
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lexical/lexer.go → syntax/lexer.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package lexical
package main

import (
"fmt"

m "github.com/Mellywins/GoLexThatJava/syntax"
"github.com/timtadh/lexmachine"
)

Expand Down
63 changes: 62 additions & 1 deletion syntax/syntax.y
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,65 @@
%union{
token *lexmachine.Token
ast *Node
}
}
/* Special tokens */
%token SPACE
%token TAB
%token BANG
%token INTEGER_LITERAL
%token BOOLEAN_LITERAL
%token IDENTIFIER
%token SINGLE_LINE_COMMENT
%token MULTI_LINE_COMMENT
%token BREAK_LINE

/* Reserved words tokens */
%token class
%token public
%token static
%token void
%token main
%token String
%token System.out.println
%token return
%token int
%token if
%token for
%token else
%token while
%token this
%token new
%token boolean
%token length
%token extends

/* Literal tokens */
%token [
%token ]
%token (
%token )
%token {
%token }
%token ,
%token ;
%token .
%token :

/* Operator tokens */
%token +
%token -
%token *
%token /
%token %
%token <
%token >
%token <=
%token >=
%token ==
%token !=
%token &&
%token ||
%token =

%% /* The grammar follows */
Program : MainClass ( ClassDeclaration )* <EOF>;

0 comments on commit 73b4315

Please sign in to comment.