Skip to content

Commit

Permalink
accepting program <x>; into ast
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Apr 16, 2012
1 parent 0503fbe commit 714a538
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions pascal/src/compiler/synanal/PascalSyn.java
@@ -1,7 +1,7 @@

//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
// Sun Apr 15 01:29:44 CEST 2012
// Mon Apr 16 10:59:34 CEST 2012
//----------------------------------------------------

package compiler.synanal;
Expand All @@ -12,7 +12,7 @@
import compiler.abstree.tree.*;

/** CUP v0.11a beta 20060608 generated parser.
* @version Sun Apr 15 01:29:44 CEST 2012
* @version Mon Apr 16 10:59:34 CEST 2012
*/
public class PascalSyn extends java_cup.runtime.lr_parser {

Expand Down Expand Up @@ -1304,13 +1304,13 @@ class CUP$PascalSyn$actions {
Object subs = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;

System.out.println("HELLO WORLD");
AbsDecls decls = new AbsDecls();
decls.decls.addAll(((AbsDecls)consts).decls);
/* AbsDecls decls = new AbsDecls();
/* decls.decls.addAll(((AbsDecls)consts).decls);
/* decls.decls.addAll(((AbsDecls)types).decls);
decls.decls.addAll(((AbsDecls)vars).decls);
decls.decls.addAll(((AbsDecls)subs).decls);*/

RESULT = decls;
// RESULT = decls;

CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("declaration",2, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
Expand Down Expand Up @@ -1351,7 +1351,7 @@ class CUP$PascalSyn$actions {
int mainblockright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
Object mainblock = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;

System.out.println("HELLO WORLD");
System.out.println("HELLO WORLD 1");
AbsProgram program = new AbsProgram((AbsDeclName)p,
(AbsDecls)decl,
(AbsBlockStmt)mainblock
Expand Down
2 changes: 1 addition & 1 deletion pascal/src/compiler/synanal/PascalTok.java
@@ -1,7 +1,7 @@

//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
// Sun Apr 15 01:29:44 CEST 2012
// Mon Apr 16 10:59:34 CEST 2012
//----------------------------------------------------

package compiler.synanal;
Expand Down
8 changes: 3 additions & 5 deletions pascal/src/compiler/synanal/pascal.cup
Expand Up @@ -50,7 +50,6 @@ start with source;

source ::= program:p declaration:decl block_statement:mainblock DOT
{:
System.out.println("HELLO WORLD");
AbsProgram program = new AbsProgram((AbsDeclName)p,
(AbsDecls)decl,
(AbsBlockStmt)mainblock
Expand All @@ -61,14 +60,13 @@ source ::= program:p declaration:decl block_statement:mainblock DOT
program ::= | PROGRAM IDENTIFIER:id SEMIC {: RESULT = new AbsDeclName(id); :};
declaration ::= constant:consts type:types var:vars subroutine:subs
{:
System.out.println("HELLO WORLD");
AbsDecls decls = new AbsDecls();
decls.decls.addAll(((AbsDecls)consts).decls);
/*AbsDecls decls = new AbsDecls();
/* decls.decls.addAll(((AbsDecls)consts).decls);
/* decls.decls.addAll(((AbsDecls)types).decls);
decls.decls.addAll(((AbsDecls)vars).decls);
decls.decls.addAll(((AbsDecls)subs).decls);*/

RESULT = decls;
// RESULT = decls;
:};

/*
Expand Down
4 changes: 3 additions & 1 deletion test/ast.pascal
@@ -1,5 +1,7 @@

const a=5;
program abstree;

{const a=5;}

begin
end.

0 comments on commit 714a538

Please sign in to comment.