From 7c1bbf7504c50b6e3465b9d05b5cc319f8c634db Mon Sep 17 00:00:00 2001 From: "Safey A.Halim" Date: Thu, 21 Oct 2010 15:21:29 +0000 Subject: [PATCH] Monkey is able to either send emails for detected crashes or dump its output in a text file. test_monkey_npe.sh: Verifies Monkey's detection of Null Pointer Exceptions. --- src/monkey/C.out.jj | 2546 +++++++++++++++++++++++++++++++++ src/monkey/Makefile.am | 27 +- src/monkey/gnunet-monkey.c | 46 +- src/monkey/test_monkey_npe.sh | 12 +- 4 files changed, 2609 insertions(+), 22 deletions(-) create mode 100644 src/monkey/C.out.jj diff --git a/src/monkey/C.out.jj b/src/monkey/C.out.jj new file mode 100644 index 000000000..fb999dd53 --- /dev/null +++ b/src/monkey/C.out.jj @@ -0,0 +1,2546 @@ +// +// Generated by JTB 1.3.2 +// + + + +PARSER_BEGIN(CParser) +import java.util.*; +import org.gnunet.monkey.parser.nodes.*; +import java.util.Vector; + + +public class CParser +{ + public static void main(String args[]) + { + CParser parser; + if ( args.length == 0 ) + { + System.out.println("C Parser Version 0.1Alpha: Reading from standard input . . ."); + parser = new CParser(System.in); + } + else + if ( args.length == 1 ) + { + System.out.println("C Parser Version 0.1Alpha: Reading from file " + args[0]+ " . . ."); + try + { + parser = new CParser(new java.io.FileInputStream(args[0])); + } + catch (java.io.FileNotFoundException e) + { + System.out.println("C Parser Version 0.1: File " + args[0]+ " not found."); + return; + } + } + else + { + System.out.println("C Parser Version 0.1Alpha: Usage is one of:"); + System.out.println(" java CParser < inputfile"); + System.out.println("OR"); + System.out.println(" java CParser inputfile"); + return; + } + try + { + parser.TranslationUnit(); + System.out.println("C Parser Version 0.1Alpha: Java program parsed successfully."); + } + catch (ParseException e) + { + System.out.println("C Parser Version 0.1Alpha: Encountered errors during parse."); + e.printStackTrace(); + } + } +} + +class JTBToolkit { + static NodeToken makeNodeToken(Token t) { + return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn); + } +} + + +PARSER_END(CParser) + +SKIP : +{ + " " + | "\t" + | "\n" + | "\r" + | <"//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")> + | <"/*" (~["*"])* "*" ("*" | ~["*", "/"] (~["*"])* "*")* "/"> + | "#" : PREPROCESSOR_OUTPUT +} + + SKIP : +{ + "\n" : DEFAULT +} + + MORE : +{ + "\\\n" + | "\\\r\n" + | <~[]> +} + +TOKEN : +{ + (["l", "L"])? (["l", "L"])? | (["l", "L"])? (["l", "L"])? | (["l", "L"])? (["l", "L"])?> + | <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])*> + | <#HEX_LITERAL: "0" ["x", "X"] (["0"-"9", "a"-"f", "A"-"F"])+> + | <#OCTAL_LITERAL: "0" (["0"-"7"])*> + | )? (["f", "F", "d", "D"])? | "." (["0"-"9"])+ ()? (["f", "F", "d", "D"])? | (["0"-"9"])+ (["f", "F", "d", "D"])? | (["0"-"9"])+ ()? ["f", "F", "d", "D"]> + | <#EXPONENT: ["e", "E"] (["+", "-"])? (["0"-"9"])+> + | + | +} + +TOKEN : +{ + + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | +} + +TOKEN : +{ + ( | )*> + | <#LETTER: ["$", "A"-"Z", "_", "a"-"z"]> + | <#DIGIT: ["0"-"9"]> +} + +TranslationUnit TranslationUnit() : +{ + NodeList n0 = new NodeList(); + ExternalDeclaration n1; + + +} +{ + ( + n1=ExternalDeclaration() + { n0.addNode(n1); } + )+ + { n0.nodes.trimToSize(); } + + { return new TranslationUnit(n0); } +} + +ExternalDeclaration ExternalDeclaration() : +{ + NodeListOptional n0 = new NodeListOptional(); + StorageClassSpecifier n1; + NodeChoice n2; + FunctionDeclaration n3; + StructOrUnionSpecifier n4; + VariableDeclaration n5; + TypeDeclaration n6; + + +} +{ + ( + n1=StorageClassSpecifier() + { n0.addNode(n1); } + )* + { n0.nodes.trimToSize(); } + ( + ( + LOOKAHEAD(FunctionDeclaration()) + n3=FunctionDeclaration() + { n2 = new NodeChoice(n3, 0); } + | + LOOKAHEAD(StructOrUnionSpecifier()) + n4=StructOrUnionSpecifier() + { n2 = new NodeChoice(n4, 1); } + | + LOOKAHEAD(VariableDeclaration()) + n5=VariableDeclaration() + { n2 = new NodeChoice(n5, 2); } + | + LOOKAHEAD(TypeDeclaration()) + n6=TypeDeclaration() + { n2 = new NodeChoice(n6, 3); } + ) + + ) + + { return new ExternalDeclaration(n0,n2); } +} + +FunctionDeclaration FunctionDeclaration() : +{ + TypeSpecifier n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + NodeOptional n5 = new NodeOptional(); + ParameterList n6; + NodeToken n7; + Token n8; + NodeChoice n9; + NodeToken n10; + Token n11; + CompoundStatement n12; + + +} +{ + n0=TypeSpecifier() + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + n4="(" { n3 = JTBToolkit.makeNodeToken(n4); } + ( + n6=ParameterList() + { n5.addNode(n6); } + )? + n8=")" { n7 = JTBToolkit.makeNodeToken(n8); } + ( + ( + n11=";" { n10 = JTBToolkit.makeNodeToken(n11); } + { n9 = new NodeChoice(n10, 0); } + | + n12=CompoundStatement() + { n9 = new NodeChoice(n12, 1); } + ) + + ) + + { return new FunctionDeclaration(n0,n1,n3,n5,n7,n9); } +} + +StorageClassSpecifier StorageClassSpecifier() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + + +} +{ + ( + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n4= { n3 = JTBToolkit.makeNodeToken(n4); } + { n0 = new NodeChoice(n3, 1); } + ) + + ) + + { return new StorageClassSpecifier(n0); } +} + +TypeDeclaration TypeDeclaration() : +{ + NodeToken n0; + Token n1; + NodeChoice n2; + DataType n3; + FunctionType n4; + NodeToken n5; + Token n6; + + +} +{ + n1= { n0 = JTBToolkit.makeNodeToken(n1); } + ( + ( + LOOKAHEAD(DataType() ";") + n3=DataType() + { n2 = new NodeChoice(n3, 0); } + | + n4=FunctionType() + { n2 = new NodeChoice(n4, 1); } + ) + + ) + n6=";" { n5 = JTBToolkit.makeNodeToken(n6); } + + { return new TypeDeclaration(n0,n2,n5); } +} + +DataType DataType() : +{ + StructOrUnionSpecifier n0; + NodeToken n1; + Token n2; + + +} +{ + n0=StructOrUnionSpecifier() + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + + { return new DataType(n0,n1); } +} + +FunctionType FunctionType() : +{ + TypeSpecifier n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + NodeToken n5; + Token n6; + NodeToken n7; + Token n8; + NodeToken n9; + Token n10; + NodeOptional n11 = new NodeOptional(); + ParameterList n12; + NodeToken n13; + Token n14; + + +} +{ + n0=TypeSpecifier() + n2="(" { n1 = JTBToolkit.makeNodeToken(n2); } + n4="*" { n3 = JTBToolkit.makeNodeToken(n4); } + n6= { n5 = JTBToolkit.makeNodeToken(n6); } + n8=")" { n7 = JTBToolkit.makeNodeToken(n8); } + n10="(" { n9 = JTBToolkit.makeNodeToken(n10); } + ( + n12=ParameterList() + { n11.addNode(n12); } + )? + n14=")" { n13 = JTBToolkit.makeNodeToken(n14); } + + { return new FunctionType(n0,n1,n3,n5,n7,n9,n11,n13); } +} + +ParameterList ParameterList() : +{ + ParameterDeclaration n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + ParameterDeclaration n5; + NodeOptional n6 = new NodeOptional(); + NodeSequence n7; + NodeToken n8; + Token n9; + NodeToken n10; + Token n11; + + +} +{ + n0=ParameterDeclaration() + ( + LOOKAHEAD(2) + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=ParameterDeclaration() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + ( + { n7 = new NodeSequence(2); } + n9="," { n8 = JTBToolkit.makeNodeToken(n9); } + { n7.addNode(n8); } + n11="..." { n10 = JTBToolkit.makeNodeToken(n11); } + { n7.addNode(n10); } + { n6.addNode(n7); } + )? + + { return new ParameterList(n0,n1,n6); } +} + +ParameterDeclaration ParameterDeclaration() : +{ + TypeSpecifier n0; + NodeToken n1; + Token n2; + NodeOptional n3 = new NodeOptional(); + Array n4; + + +} +{ + n0=TypeSpecifier() + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + ( + n4=Array() + { n3.addNode(n4); } + )? + + { return new ParameterDeclaration(n0,n1,n3); } +} + +VariableDeclaration VariableDeclaration() : +{ + VariableClassSpecifier n0; + TypeSpecifier n1; + InitDeclaratorList n2; + NodeToken n3; + Token n4; + + +} +{ + n0=VariableClassSpecifier() + n1=TypeSpecifier() + n2=InitDeclaratorList() + n4=";" { n3 = JTBToolkit.makeNodeToken(n4); } + + { return new VariableDeclaration(n0,n1,n2,n3); } +} + +LocalVariableDeclaration LocalVariableDeclaration() : +{ + NodeOptional n0 = new NodeOptional(); + NodeToken n1; + Token n2; + VariableDeclaration n3; + + +} +{ + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0.addNode(n1); } + )? + n3=VariableDeclaration() + + { return new LocalVariableDeclaration(n0,n3); } +} + +VariableClassSpecifier VariableClassSpecifier() : +{ + NodeListOptional n0 = new NodeListOptional(); + NodeChoice n1; + NodeToken n2; + Token n3; + NodeToken n4; + Token n5; + + +} +{ + ( + ( + n3= { n2 = JTBToolkit.makeNodeToken(n3); } + { n1 = new NodeChoice(n2, 0); } + | + n5= { n4 = JTBToolkit.makeNodeToken(n5); } + { n1 = new NodeChoice(n4, 1); } + ) + { n0.addNode(n1); } + )* + { n0.nodes.trimToSize(); } + + { return new VariableClassSpecifier(n0); } +} + +TypeSpecifier TypeSpecifier() : +{ + NodeOptional n0 = new NodeOptional(); + NodeToken n1; + Token n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + NodeSequence n8; + NodeToken n9; + Token n10; + NodeOptional n11 = new NodeOptional(); + NodeToken n12; + Token n13; + NodeToken n14; + Token n15; + NodeSequence n16; + NodeToken n17; + Token n18; + NodeOptional n19 = new NodeOptional(); + NodeToken n20; + Token n21; + NodeToken n22; + Token n23; + NodeToken n24; + Token n25; + NodeSequence n26; + NodeChoice n27; + NodeToken n28; + Token n29; + NodeToken n30; + Token n31; + NodeOptional n32 = new NodeOptional(); + NodeChoice n33; + NodeToken n34; + Token n35; + NodeSequence n36; + NodeToken n37; + Token n38; + NodeOptional n39; + NodeToken n40; + Token n41; + NodeToken n42; + Token n43; + NodeSequence n44; + NodeToken n45; + Token n46; + NodeOptional n47; + NodeToken n48; + Token n49; + StructOrUnionSpecifier n50; + EnumSpecifier n51; + NodeToken n52; + Token n53; + NodeOptional n54 = new NodeOptional(); + Pointer n55; + NodeOptional n56 = new NodeOptional(); + Array n57; + + +} +{ + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0.addNode(n1); } + )? + ( + ( + n5= { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7= { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + | + { n8 = new NodeSequence(2); } + n10= { n9 = JTBToolkit.makeNodeToken(n10); } + { n8.addNode(n9); } + ( + n13= { n12 = JTBToolkit.makeNodeToken(n13); } + { n11.addNode(n12); } + )? + { n8.addNode(n11); } + { n3 = new NodeChoice(n8, 2); } + | + n15= { n14 = JTBToolkit.makeNodeToken(n15); } + { n3 = new NodeChoice(n14, 3); } + | + { n16 = new NodeSequence(2); } + n18= { n17 = JTBToolkit.makeNodeToken(n18); } + { n16.addNode(n17); } + ( + n21= { n20 = JTBToolkit.makeNodeToken(n21); } + { n19.addNode(n20); } + )? + { n16.addNode(n19); } + { n3 = new NodeChoice(n16, 4); } + | + n23= { n22 = JTBToolkit.makeNodeToken(n23); } + { n3 = new NodeChoice(n22, 5); } + | + n25= { n24 = JTBToolkit.makeNodeToken(n25); } + { n3 = new NodeChoice(n24, 6); } + | + { n26 = new NodeSequence(2); } + ( + ( + n29= { n28 = JTBToolkit.makeNodeToken(n29); } + { n27 = new NodeChoice(n28, 0); } + | + n31= { n30 = JTBToolkit.makeNodeToken(n31); } + { n27 = new NodeChoice(n30, 1); } + ) + + ) + { n26.addNode(n27); } + ( + { n39 = new NodeOptional(); } + { n47 = new NodeOptional(); } + ( + n35= { n34 = JTBToolkit.makeNodeToken(n35); } + { n33 = new NodeChoice(n34, 0); } + | + { n36 = new NodeSequence(2); } + n38= { n37 = JTBToolkit.makeNodeToken(n38); } + { n36.addNode(n37); } + ( + n41= { n40 = JTBToolkit.makeNodeToken(n41); } + { n39.addNode(n40); } + )? + { n36.addNode(n39); } + { n33 = new NodeChoice(n36, 1); } + | + n43= { n42 = JTBToolkit.makeNodeToken(n43); } + { n33 = new NodeChoice(n42, 2); } + | + { n44 = new NodeSequence(2); } + n46= { n45 = JTBToolkit.makeNodeToken(n46); } + { n44.addNode(n45); } + ( + n49= { n48 = JTBToolkit.makeNodeToken(n49); } + { n47.addNode(n48); } + )? + { n44.addNode(n47); } + { n33 = new NodeChoice(n44, 3); } + ) + { n32.addNode(n33); } + )? + { n26.addNode(n32); } + { n3 = new NodeChoice(n26, 7); } + | + n50=StructOrUnionSpecifier() + { n3 = new NodeChoice(n50, 8); } + | + n51=EnumSpecifier() + { n3 = new NodeChoice(n51, 9); } + | + n53= { n52 = JTBToolkit.makeNodeToken(n53); } + { n3 = new NodeChoice(n52, 10); } + ) + + ) + ( + n55=Pointer() + { n54.addNode(n55); } + )? + ( + n57=Array() + { n56.addNode(n57); } + )? + + { return new TypeSpecifier(n0,n3,n54,n56); } +} + +NoIdentifierTypeSpecifier NoIdentifierTypeSpecifier() : +{ + NodeOptional n0 = new NodeOptional(); + NodeToken n1; + Token n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + NodeSequence n8; + NodeToken n9; + Token n10; + NodeOptional n11 = new NodeOptional(); + NodeToken n12; + Token n13; + NodeToken n14; + Token n15; + NodeSequence n16; + NodeToken n17; + Token n18; + NodeOptional n19 = new NodeOptional(); + NodeToken n20; + Token n21; + NodeToken n22; + Token n23; + NodeToken n24; + Token n25; + NodeSequence n26; + NodeChoice n27; + NodeToken n28; + Token n29; + NodeToken n30; + Token n31; + NodeOptional n32 = new NodeOptional(); + NodeChoice n33; + NodeToken n34; + Token n35; + NodeSequence n36; + NodeToken n37; + Token n38; + NodeOptional n39; + NodeToken n40; + Token n41; + NodeToken n42; + Token n43; + NodeSequence n44; + NodeToken n45; + Token n46; + NodeOptional n47; + NodeToken n48; + Token n49; + StructOrUnionSpecifier n50; + EnumSpecifier n51; + NodeOptional n52 = new NodeOptional(); + Pointer n53; + NodeOptional n54 = new NodeOptional(); + Array n55; + + +} +{ + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0.addNode(n1); } + )? + ( + ( + n5= { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7= { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + | + { n8 = new NodeSequence(2); } + n10= { n9 = JTBToolkit.makeNodeToken(n10); } + { n8.addNode(n9); } + ( + n13= { n12 = JTBToolkit.makeNodeToken(n13); } + { n11.addNode(n12); } + )? + { n8.addNode(n11); } + { n3 = new NodeChoice(n8, 2); } + | + n15= { n14 = JTBToolkit.makeNodeToken(n15); } + { n3 = new NodeChoice(n14, 3); } + | + { n16 = new NodeSequence(2); } + n18= { n17 = JTBToolkit.makeNodeToken(n18); } + { n16.addNode(n17); } + ( + n21= { n20 = JTBToolkit.makeNodeToken(n21); } + { n19.addNode(n20); } + )? + { n16.addNode(n19); } + { n3 = new NodeChoice(n16, 4); } + | + n23= { n22 = JTBToolkit.makeNodeToken(n23); } + { n3 = new NodeChoice(n22, 5); } + | + n25= { n24 = JTBToolkit.makeNodeToken(n25); } + { n3 = new NodeChoice(n24, 6); } + | + { n26 = new NodeSequence(2); } + ( + ( + n29= { n28 = JTBToolkit.makeNodeToken(n29); } + { n27 = new NodeChoice(n28, 0); } + | + n31= { n30 = JTBToolkit.makeNodeToken(n31); } + { n27 = new NodeChoice(n30, 1); } + ) + + ) + { n26.addNode(n27); } + ( + { n39 = new NodeOptional(); } + { n47 = new NodeOptional(); } + ( + n35= { n34 = JTBToolkit.makeNodeToken(n35); } + { n33 = new NodeChoice(n34, 0); } + | + { n36 = new NodeSequence(2); } + n38= { n37 = JTBToolkit.makeNodeToken(n38); } + { n36.addNode(n37); } + ( + n41= { n40 = JTBToolkit.makeNodeToken(n41); } + { n39.addNode(n40); } + )? + { n36.addNode(n39); } + { n33 = new NodeChoice(n36, 1); } + | + n43= { n42 = JTBToolkit.makeNodeToken(n43); } + { n33 = new NodeChoice(n42, 2); } + | + { n44 = new NodeSequence(2); } + n46= { n45 = JTBToolkit.makeNodeToken(n46); } + { n44.addNode(n45); } + ( + n49= { n48 = JTBToolkit.makeNodeToken(n49); } + { n47.addNode(n48); } + )? + { n44.addNode(n47); } + { n33 = new NodeChoice(n44, 3); } + ) + { n32.addNode(n33); } + )? + { n26.addNode(n32); } + { n3 = new NodeChoice(n26, 7); } + | + n50=StructOrUnionSpecifier() + { n3 = new NodeChoice(n50, 8); } + | + n51=EnumSpecifier() + { n3 = new NodeChoice(n51, 9); } + ) + + ) + ( + n53=Pointer() + { n52.addNode(n53); } + )? + ( + n55=Array() + { n54.addNode(n55); } + )? + + { return new NoIdentifierTypeSpecifier(n0,n3,n52,n54); } +} + +StructOrUnionSpecifier StructOrUnionSpecifier() : +{ + NodeChoice n0; + NodeSequence n1; + StructOrUnion n2; + NodeOptional n3 = new NodeOptional(); + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + StructDeclarationList n8; + NodeToken n9; + Token n10; + NodeSequence n11; + StructOrUnion n12; + NodeToken n13; + Token n14; + + +} +{ + ( + LOOKAHEAD(3) + { n1 = new NodeSequence(6); } + n2=StructOrUnion() + { n1.addNode(n2); } + ( + n5= { n4 = JTBToolkit.makeNodeToken(n5); } + { n3.addNode(n4); } + )? + { n1.addNode(n3); } + n7="{" { n6 = JTBToolkit.makeNodeToken(n7); } + { n1.addNode(n6); } + n8=StructDeclarationList() + { n1.addNode(n8); } + n10="}" { n9 = JTBToolkit.makeNodeToken(n10); } + { n1.addNode(n9); } + { n0 = new NodeChoice(n1, 0); } + | + { n11 = new NodeSequence(2); } + n12=StructOrUnion() + { n11.addNode(n12); } + n14= { n13 = JTBToolkit.makeNodeToken(n14); } + { n11.addNode(n13); } + { n0 = new NodeChoice(n11, 1); } + ) + + { return new StructOrUnionSpecifier(n0); } +} + +StructOrUnion StructOrUnion() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + + +} +{ + ( + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n4= { n3 = JTBToolkit.makeNodeToken(n4); } + { n0 = new NodeChoice(n3, 1); } + ) + + ) + + { return new StructOrUnion(n0); } +} + +StructDeclarationList StructDeclarationList() : +{ + NodeList n0 = new NodeList(); + StructDeclaration n1; + + +} +{ + ( + n1=StructDeclaration() + { n0.addNode(n1); } + )+ + { n0.nodes.trimToSize(); } + + { return new StructDeclarationList(n0); } +} + +InitDeclaratorList InitDeclaratorList() : +{ + InitDeclarator n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + InitDeclarator n5; + + +} +{ + n0=InitDeclarator() + ( + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=InitDeclarator() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new InitDeclaratorList(n0,n1); } +} + +InitDeclarator InitDeclarator() : +{ + NodeToken n0; + Token n1; + NodeOptional n2 = new NodeOptional(); + Array n3; + NodeOptional n4 = new NodeOptional(); + NodeSequence n5; + NodeToken n6; + Token n7; + Initializer n8; + + +} +{ + n1= { n0 = JTBToolkit.makeNodeToken(n1); } + ( + n3=Array() + { n2.addNode(n3); } + )? + ( + { n5 = new NodeSequence(2); } + n7="=" { n6 = JTBToolkit.makeNodeToken(n7); } + { n5.addNode(n6); } + n8=Initializer() + { n5.addNode(n8); } + { n4.addNode(n5); } + )? + + { return new InitDeclarator(n0,n2,n4); } +} + +StructDeclaration StructDeclaration() : +{ + TypeSpecifier n0; + NodeToken n1; + Token n2; + NodeOptional n3 = new NodeOptional(); + NodeChoice n4; + Array n5; + NodeSequence n6; + NodeToken n7; + Token n8; + ConstantExpression n9; + NodeOptional n10 = new NodeOptional(); + NodeToken n11; + Token n12; + NodeToken n13; + Token n14; + + +} +{ + n0=TypeSpecifier() + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + ( + ( + n5=Array() + { n4 = new NodeChoice(n5, 0); } + | + { n6 = new NodeSequence(2); } + n8=":" { n7 = JTBToolkit.makeNodeToken(n8); } + { n6.addNode(n7); } + n9=ConstantExpression() + { n6.addNode(n9); } + { n4 = new NodeChoice(n6, 1); } + ) + { n3.addNode(n4); } + )? + ( + n12= { n11 = JTBToolkit.makeNodeToken(n12); } + { n10.addNode(n11); } + )? + n14=";" { n13 = JTBToolkit.makeNodeToken(n14); } + + { return new StructDeclaration(n0,n1,n3,n10,n13); } +} + +EnumSpecifier EnumSpecifier() : +{ + NodeToken n0; + Token n1; + NodeChoice n2; + NodeSequence n3; + NodeOptional n4 = new NodeOptional(); + NodeToken n5; + Token n6; + NodeToken n7; + Token n8; + EnumeratorList n9; + NodeToken n10; + Token n11; + NodeToken n12; + Token n13; + + +} +{ + n1= { n0 = JTBToolkit.makeNodeToken(n1); } + ( + ( + LOOKAHEAD(3) + { n3 = new NodeSequence(5); } + ( + n6= { n5 = JTBToolkit.makeNodeToken(n6); } + { n4.addNode(n5); } + )? + { n3.addNode(n4); } + n8="{" { n7 = JTBToolkit.makeNodeToken(n8); } + { n3.addNode(n7); } + n9=EnumeratorList() + { n3.addNode(n9); } + n11="}" { n10 = JTBToolkit.makeNodeToken(n11); } + { n3.addNode(n10); } + { n2 = new NodeChoice(n3, 0); } + | + n13= { n12 = JTBToolkit.makeNodeToken(n13); } + { n2 = new NodeChoice(n12, 1); } + ) + + ) + + { return new EnumSpecifier(n0,n2); } +} + +EnumeratorList EnumeratorList() : +{ + Enumerator n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + Enumerator n5; + + +} +{ + n0=Enumerator() + ( + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=Enumerator() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new EnumeratorList(n0,n1); } +} + +Enumerator Enumerator() : +{ + NodeToken n0; + Token n1; + NodeOptional n2 = new NodeOptional(); + NodeSequence n3; + NodeToken n4; + Token n5; + ConstantExpression n6; + + +} +{ + n1= { n0 = JTBToolkit.makeNodeToken(n1); } + ( + { n3 = new NodeSequence(2); } + n5="=" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3.addNode(n4); } + n6=ConstantExpression() + { n3.addNode(n6); } + { n2.addNode(n3); } + )? + + { return new Enumerator(n0,n2); } +} + +Pointer Pointer() : +{ + NodeToken n0; + Token n1; + NodeOptional n2 = new NodeOptional(); + NodeToken n3; + Token n4; + NodeOptional n5 = new NodeOptional(); + Pointer n6; + + +} +{ + n1="*" { n0 = JTBToolkit.makeNodeToken(n1); } + ( + n4= { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + )? + ( + n6=Pointer() + { n5.addNode(n6); } + )? + + { return new Pointer(n0,n2,n5); } +} + +IdentifierList IdentifierList() : +{ + NodeToken n0; + Token n1; + NodeListOptional n2 = new NodeListOptional(); + NodeSequence n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + + +} +{ + n1= { n0 = JTBToolkit.makeNodeToken(n1); } + ( + { n3 = new NodeSequence(2); } + n5="," { n4 = JTBToolkit.makeNodeToken(n5); } + { n3.addNode(n4); } + n7= { n6 = JTBToolkit.makeNodeToken(n7); } + { n3.addNode(n6); } + { n2.addNode(n3); } + )* + { n2.nodes.trimToSize(); } + + { return new IdentifierList(n0,n2); } +} + +Initializer Initializer() : +{ + NodeChoice n0; + AssignmentExpression n1; + NodeSequence n2; + NodeToken n3; + Token n4; + InitializerList n5; + NodeOptional n6 = new NodeOptional(); + NodeToken n7; + Token n8; + NodeToken n9; + Token n10; + + +} +{ + ( + ( + n1=AssignmentExpression() + { n0 = new NodeChoice(n1, 0); } + | + { n2 = new NodeSequence(4); } + n4="{" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=InitializerList() + { n2.addNode(n5); } + ( + n8="," { n7 = JTBToolkit.makeNodeToken(n8); } + { n6.addNode(n7); } + )? + { n2.addNode(n6); } + n10="}" { n9 = JTBToolkit.makeNodeToken(n10); } + { n2.addNode(n9); } + { n0 = new NodeChoice(n2, 1); } + ) + + ) + + { return new Initializer(n0); } +} + +InitializerList InitializerList() : +{ + Initializer n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + Initializer n5; + + +} +{ + n0=Initializer() + ( + LOOKAHEAD(2) + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=Initializer() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new InitializerList(n0,n1); } +} + +Array Array() : +{ + NodeToken n0; + Token n1; + NodeOptional n2 = new NodeOptional(); + ConstantExpression n3; + NodeToken n4; + Token n5; + + +} +{ + n1="[" { n0 = JTBToolkit.makeNodeToken(n1); } + ( + n3=ConstantExpression() + { n2.addNode(n3); } + )? + n5="]" { n4 = JTBToolkit.makeNodeToken(n5); } + + { return new Array(n0,n2,n4); } +} + +Statement Statement() : +{ + NodeChoice n0; + LabeledStatement n1; + ExpressionStatement n2; + CompoundStatement n3; + SelectionStatement n4; + IterationStatement n5; + JumpStatement n6; + + +} +{ + ( + ( + LOOKAHEAD(2) + n1=LabeledStatement() + { n0 = new NodeChoice(n1, 0); } + | + n2=ExpressionStatement() + { n0 = new NodeChoice(n2, 1); } + | + n3=CompoundStatement() + { n0 = new NodeChoice(n3, 2); } + | + n4=SelectionStatement() + { n0 = new NodeChoice(n4, 3); } + | + n5=IterationStatement() + { n0 = new NodeChoice(n5, 4); } + | + n6=JumpStatement() + { n0 = new NodeChoice(n6, 5); } + ) + + ) + + { return new Statement(n0); } +} + +LabeledStatement LabeledStatement() : +{ + NodeChoice n0; + NodeSequence n1; + NodeToken n2; + Token n3; + NodeToken n4; + Token n5; + Statement n6; + NodeSequence n7; + NodeToken n8; + Token n9; + ConstantExpression n10; + NodeToken n11; + Token n12; + Statement n13; + NodeSequence n14; + NodeToken n15; + Token n16; + NodeToken n17; + Token n18; + Statement n19; + + +} +{ + ( + ( + { n1 = new NodeSequence(3); } + n3= { n2 = JTBToolkit.makeNodeToken(n3); } + { n1.addNode(n2); } + n5=":" { n4 = JTBToolkit.makeNodeToken(n5); } + { n1.addNode(n4); } + n6=Statement() + { n1.addNode(n6); } + { n0 = new NodeChoice(n1, 0); } + | + { n7 = new NodeSequence(4); } + n9= { n8 = JTBToolkit.makeNodeToken(n9); } + { n7.addNode(n8); } + n10=ConstantExpression() + { n7.addNode(n10); } + n12=":" { n11 = JTBToolkit.makeNodeToken(n12); } + { n7.addNode(n11); } + n13=Statement() + { n7.addNode(n13); } + { n0 = new NodeChoice(n7, 1); } + | + { n14 = new NodeSequence(3); } + n16= { n15 = JTBToolkit.makeNodeToken(n16); } + { n14.addNode(n15); } + n18=":" { n17 = JTBToolkit.makeNodeToken(n18); } + { n14.addNode(n17); } + n19=Statement() + { n14.addNode(n19); } + { n0 = new NodeChoice(n14, 2); } + ) + + ) + + { return new LabeledStatement(n0); } +} + +ExpressionStatement ExpressionStatement() : +{ + NodeOptional n0 = new NodeOptional(); + Expression n1; + NodeToken n2; + Token n3; + + +} +{ + ( + n1=Expression() + { n0.addNode(n1); } + )? + n3=";" { n2 = JTBToolkit.makeNodeToken(n3); } + + { return new ExpressionStatement(n0,n2); } +} + +CompoundStatement CompoundStatement() : +{ + NodeToken n0; + Token n1; + NodeListOptional n2 = new NodeListOptional(); + NodeChoice n3; + LocalVariableDeclaration n4; + Statement n5; + NodeToken n6; + Token n7; + + +} +{ + n1="{" { n0 = JTBToolkit.makeNodeToken(n1); } + ( + ( + LOOKAHEAD(LocalVariableDeclaration()) + n4=LocalVariableDeclaration() + { n3 = new NodeChoice(n4, 0); } + | + n5=Statement() + { n3 = new NodeChoice(n5, 1); } + ) + { n2.addNode(n3); } + )* + { n2.nodes.trimToSize(); } + n7="}" { n6 = JTBToolkit.makeNodeToken(n7); } + + { return new CompoundStatement(n0,n2,n6); } +} + +SelectionStatement SelectionStatement() : +{ + NodeChoice n0; + NodeSequence n1; + NodeToken n2; + Token n3; + NodeToken n4; + Token n5; + Expression n6; + NodeToken n7; + Token n8; + Statement n9; + NodeOptional n10 = new NodeOptional(); + NodeSequence n11; + NodeToken n12; + Token n13; + Statement n14; + NodeSequence n15; + NodeToken n16; + Token n17; + NodeToken n18; + Token n19; + Expression n20; + NodeToken n21; + Token n22; + Statement n23; + + +} +{ + ( + ( + { n1 = new NodeSequence(6); } + n3= { n2 = JTBToolkit.makeNodeToken(n3); } + { n1.addNode(n2); } + n5="(" { n4 = JTBToolkit.makeNodeToken(n5); } + { n1.addNode(n4); } + n6=Expression() + { n1.addNode(n6); } + n8=")" { n7 = JTBToolkit.makeNodeToken(n8); } + { n1.addNode(n7); } + n9=Statement() + { n1.addNode(n9); } + ( + LOOKAHEAD(2) + { n11 = new NodeSequence(2); } + n13= { n12 = JTBToolkit.makeNodeToken(n13); } + { n11.addNode(n12); } + n14=Statement() + { n11.addNode(n14); } + { n10.addNode(n11); } + )? + { n1.addNode(n10); } + { n0 = new NodeChoice(n1, 0); } + | + { n15 = new NodeSequence(5); } + n17= { n16 = JTBToolkit.makeNodeToken(n17); } + { n15.addNode(n16); } + n19="(" { n18 = JTBToolkit.makeNodeToken(n19); } + { n15.addNode(n18); } + n20=Expression() + { n15.addNode(n20); } + n22=")" { n21 = JTBToolkit.makeNodeToken(n22); } + { n15.addNode(n21); } + n23=Statement() + { n15.addNode(n23); } + { n0 = new NodeChoice(n15, 1); } + ) + + ) + + { return new SelectionStatement(n0); } +} + +IterationStatement IterationStatement() : +{ + NodeChoice n0; + NodeSequence n1; + NodeToken n2; + Token n3; + NodeToken n4; + Token n5; + Expression n6; + NodeToken n7; + Token n8; + Statement n9; + NodeSequence n10; + NodeToken n11; + Token n12; + Statement n13; + NodeToken n14; + Token n15; + NodeToken n16; + Token n17; + Expression n18; + NodeToken n19; + Token n20; + NodeToken n21; + Token n22; + NodeSequence n23; + NodeToken n24; + Token n25; + NodeToken n26; + Token n27; + NodeOptional n28 = new NodeOptional(); + Expression n29; + NodeToken n30; + Token n31; + NodeOptional n32 = new NodeOptional(); + Expression n33; + NodeToken n34; + Token n35; + NodeOptional n36 = new NodeOptional(); + Expression n37; + NodeToken n38; + Token n39; + Statement n40; + + +} +{ + ( + ( + { n1 = new NodeSequence(5); } + n3= { n2 = JTBToolkit.makeNodeToken(n3); } + { n1.addNode(n2); } + n5="(" { n4 = JTBToolkit.makeNodeToken(n5); } + { n1.addNode(n4); } + n6=Expression() + { n1.addNode(n6); } + n8=")" { n7 = JTBToolkit.makeNodeToken(n8); } + { n1.addNode(n7); } + n9=Statement() + { n1.addNode(n9); } + { n0 = new NodeChoice(n1, 0); } + | + { n10 = new NodeSequence(7); } + n12= { n11 = JTBToolkit.makeNodeToken(n12); } + { n10.addNode(n11); } + n13=Statement() + { n10.addNode(n13); } + n15= { n14 = JTBToolkit.makeNodeToken(n15); } + { n10.addNode(n14); } + n17="(" { n16 = JTBToolkit.makeNodeToken(n17); } + { n10.addNode(n16); } + n18=Expression() + { n10.addNode(n18); } + n20=")" { n19 = JTBToolkit.makeNodeToken(n20); } + { n10.addNode(n19); } + n22=";" { n21 = JTBToolkit.makeNodeToken(n22); } + { n10.addNode(n21); } + { n0 = new NodeChoice(n10, 1); } + | + { n23 = new NodeSequence(9); } + n25= { n24 = JTBToolkit.makeNodeToken(n25); } + { n23.addNode(n24); } + n27="(" { n26 = JTBToolkit.makeNodeToken(n27); } + { n23.addNode(n26); } + ( + n29=Expression() + { n28.addNode(n29); } + )? + { n23.addNode(n28); } + n31=";" { n30 = JTBToolkit.makeNodeToken(n31); } + { n23.addNode(n30); } + ( + n33=Expression() + { n32.addNode(n33); } + )? + { n23.addNode(n32); } + n35=";" { n34 = JTBToolkit.makeNodeToken(n35); } + { n23.addNode(n34); } + ( + n37=Expression() + { n36.addNode(n37); } + )? + { n23.addNode(n36); } + n39=")" { n38 = JTBToolkit.makeNodeToken(n39); } + { n23.addNode(n38); } + n40=Statement() + { n23.addNode(n40); } + { n0 = new NodeChoice(n23, 2); } + ) + + ) + + { return new IterationStatement(n0); } +} + +JumpStatement JumpStatement() : +{ + NodeChoice n0; + NodeSequence n1; + NodeToken n2; + Token n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + NodeSequence n8; + NodeToken n9; + Token n10; + NodeToken n11; + Token n12; + NodeSequence n13; + NodeToken n14; + Token n15; + NodeToken n16; + Token n17; + NodeSequence n18; + NodeToken n19; + Token n20; + NodeOptional n21 = new NodeOptional(); + Expression n22; + NodeToken n23; + Token n24; + + +} +{ + ( + ( + { n1 = new NodeSequence(3); } + n3= { n2 = JTBToolkit.makeNodeToken(n3); } + { n1.addNode(n2); } + n5= { n4 = JTBToolkit.makeNodeToken(n5); } + { n1.addNode(n4); } + n7=";" { n6 = JTBToolkit.makeNodeToken(n7); } + { n1.addNode(n6); } + { n0 = new NodeChoice(n1, 0); } + | + { n8 = new NodeSequence(2); } + n10= { n9 = JTBToolkit.makeNodeToken(n10); } + { n8.addNode(n9); } + n12=";" { n11 = JTBToolkit.makeNodeToken(n12); } + { n8.addNode(n11); } + { n0 = new NodeChoice(n8, 1); } + | + { n13 = new NodeSequence(2); } + n15= { n14 = JTBToolkit.makeNodeToken(n15); } + { n13.addNode(n14); } + n17=";" { n16 = JTBToolkit.makeNodeToken(n17); } + { n13.addNode(n16); } + { n0 = new NodeChoice(n13, 2); } + | + { n18 = new NodeSequence(3); } + n20= { n19 = JTBToolkit.makeNodeToken(n20); } + { n18.addNode(n19); } + ( + n22=Expression() + { n21.addNode(n22); } + )? + { n18.addNode(n21); } + n24=";" { n23 = JTBToolkit.makeNodeToken(n24); } + { n18.addNode(n23); } + { n0 = new NodeChoice(n18, 3); } + ) + + ) + + { return new JumpStatement(n0); } +} + +Expression Expression() : +{ + AssignmentExpression n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + AssignmentExpression n5; + + +} +{ + n0=AssignmentExpression() + ( + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=AssignmentExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new Expression(n0,n1); } +} + +AssignmentExpression AssignmentExpression() : +{ + NodeChoice n0; + NodeSequence n1; + UnaryExpression n2; + AssignmentOperator n3; + AssignmentExpression n4; + ConditionalExpression n5; + + +} +{ + ( + LOOKAHEAD(UnaryExpression() AssignmentOperator()) + { n1 = new NodeSequence(4); } + n2=UnaryExpression() + { n1.addNode(n2); } + n3=AssignmentOperator() + { n1.addNode(n3); } + n4=AssignmentExpression() + { n1.addNode(n4); } + { n0 = new NodeChoice(n1, 0); } + | + LOOKAHEAD(3) + n5=ConditionalExpression() + { n0 = new NodeChoice(n5, 1); } + ) + + { return new AssignmentExpression(n0); } +} + +AssignmentOperator AssignmentOperator() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + NodeToken n5; + Token n6; + NodeToken n7; + Token n8; + NodeToken n9; + Token n10; + NodeToken n11; + Token n12; + NodeToken n13; + Token n14; + NodeToken n15; + Token n16; + NodeToken n17; + Token n18; + NodeToken n19; + Token n20; + NodeToken n21; + Token n22; + + +} +{ + ( + ( + n2="=" { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n4="*=" { n3 = JTBToolkit.makeNodeToken(n4); } + { n0 = new NodeChoice(n3, 1); } + | + n6="/=" { n5 = JTBToolkit.makeNodeToken(n6); } + { n0 = new NodeChoice(n5, 2); } + | + n8="%=" { n7 = JTBToolkit.makeNodeToken(n8); } + { n0 = new NodeChoice(n7, 3); } + | + n10="+=" { n9 = JTBToolkit.makeNodeToken(n10); } + { n0 = new NodeChoice(n9, 4); } + | + n12="-=" { n11 = JTBToolkit.makeNodeToken(n12); } + { n0 = new NodeChoice(n11, 5); } + | + n14="<<=" { n13 = JTBToolkit.makeNodeToken(n14); } + { n0 = new NodeChoice(n13, 6); } + | + n16=">>=" { n15 = JTBToolkit.makeNodeToken(n16); } + { n0 = new NodeChoice(n15, 7); } + | + n18="&=" { n17 = JTBToolkit.makeNodeToken(n18); } + { n0 = new NodeChoice(n17, 8); } + | + n20="^=" { n19 = JTBToolkit.makeNodeToken(n20); } + { n0 = new NodeChoice(n19, 9); } + | + n22="|=" { n21 = JTBToolkit.makeNodeToken(n22); } + { n0 = new NodeChoice(n21, 10); } + ) + + ) + + { return new AssignmentOperator(n0); } +} + +ConditionalExpression ConditionalExpression() : +{ + LogicalORExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + Expression n5; + NodeToken n6; + Token n7; + ConditionalExpression n8; + + +} +{ + n0=LogicalORExpression() + ( + { n2 = new NodeSequence(4); } + n4="?" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=Expression() + { n2.addNode(n5); } + n7=":" { n6 = JTBToolkit.makeNodeToken(n7); } + { n2.addNode(n6); } + n8=ConditionalExpression() + { n2.addNode(n8); } + { n1.addNode(n2); } + )? + + { return new ConditionalExpression(n0,n1); } +} + +ConstantExpression ConstantExpression() : +{ + ConditionalExpression n0; + + +} +{ + n0=ConditionalExpression() + + { return new ConstantExpression(n0); } +} + +LogicalORExpression LogicalORExpression() : +{ + LogicalANDExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + LogicalORExpression n5; + + +} +{ + n0=LogicalANDExpression() + ( + { n2 = new NodeSequence(2); } + n4="||" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=LogicalORExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )? + + { return new LogicalORExpression(n0,n1); } +} + +LogicalANDExpression LogicalANDExpression() : +{ + InclusiveORExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + LogicalANDExpression n5; + + +} +{ + n0=InclusiveORExpression() + ( + { n2 = new NodeSequence(2); } + n4="&&" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=LogicalANDExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )? + + { return new LogicalANDExpression(n0,n1); } +} + +InclusiveORExpression InclusiveORExpression() : +{ + ExclusiveORExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + InclusiveORExpression n5; + + +} +{ + n0=ExclusiveORExpression() + ( + { n2 = new NodeSequence(2); } + n4="|" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=InclusiveORExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )? + + { return new InclusiveORExpression(n0,n1); } +} + +ExclusiveORExpression ExclusiveORExpression() : +{ + ANDExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + ExclusiveORExpression n5; + + +} +{ + n0=ANDExpression() + ( + { n2 = new NodeSequence(2); } + n4="^" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=ExclusiveORExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )? + + { return new ExclusiveORExpression(n0,n1); } +} + +ANDExpression ANDExpression() : +{ + EqualityExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + ANDExpression n5; + + +} +{ + n0=EqualityExpression() + ( + { n2 = new NodeSequence(2); } + n4="&" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=ANDExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )? + + { return new ANDExpression(n0,n1); } +} + +EqualityExpression EqualityExpression() : +{ + RelationalExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + EqualityExpression n8; + + +} +{ + n0=RelationalExpression() + ( + { n2 = new NodeSequence(2); } + ( + ( + n5="==" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7="!=" { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + ) + + ) + { n2.addNode(n3); } + n8=EqualityExpression() + { n2.addNode(n8); } + { n1.addNode(n2); } + )? + + { return new EqualityExpression(n0,n1); } +} + +RelationalExpression RelationalExpression() : +{ + ShiftExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + NodeToken n8; + Token n9; + NodeToken n10; + Token n11; + RelationalExpression n12; + + +} +{ + n0=ShiftExpression() + ( + { n2 = new NodeSequence(2); } + ( + ( + n5="<" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7=">" { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + | + n9="<=" { n8 = JTBToolkit.makeNodeToken(n9); } + { n3 = new NodeChoice(n8, 2); } + | + n11=">=" { n10 = JTBToolkit.makeNodeToken(n11); } + { n3 = new NodeChoice(n10, 3); } + ) + + ) + { n2.addNode(n3); } + n12=RelationalExpression() + { n2.addNode(n12); } + { n1.addNode(n2); } + )? + + { return new RelationalExpression(n0,n1); } +} + +ShiftExpression ShiftExpression() : +{ + AdditiveExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + ShiftExpression n8; + + +} +{ + n0=AdditiveExpression() + ( + { n2 = new NodeSequence(2); } + ( + ( + n5="<<" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7=">>" { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + ) + + ) + { n2.addNode(n3); } + n8=ShiftExpression() + { n2.addNode(n8); } + { n1.addNode(n2); } + )? + + { return new ShiftExpression(n0,n1); } +} + +AdditiveExpression AdditiveExpression() : +{ + MultiplicativeExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + AdditiveExpression n8; + + +} +{ + n0=MultiplicativeExpression() + ( + { n2 = new NodeSequence(2); } + ( + ( + n5="+" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7="-" { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + ) + + ) + { n2.addNode(n3); } + n8=AdditiveExpression() + { n2.addNode(n8); } + { n1.addNode(n2); } + )? + + { return new AdditiveExpression(n0,n1); } +} + +MultiplicativeExpression MultiplicativeExpression() : +{ + CastExpression n0; + NodeOptional n1 = new NodeOptional(); + NodeSequence n2; + NodeChoice n3; + NodeToken n4; + Token n5; + NodeToken n6; + Token n7; + NodeToken n8; + Token n9; + MultiplicativeExpression n10; + + +} +{ + n0=CastExpression() + ( + { n2 = new NodeSequence(2); } + ( + ( + n5="*" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3 = new NodeChoice(n4, 0); } + | + n7="/" { n6 = JTBToolkit.makeNodeToken(n7); } + { n3 = new NodeChoice(n6, 1); } + | + n9="%" { n8 = JTBToolkit.makeNodeToken(n9); } + { n3 = new NodeChoice(n8, 2); } + ) + + ) + { n2.addNode(n3); } + n10=MultiplicativeExpression() + { n2.addNode(n10); } + { n1.addNode(n2); } + )? + + { return new MultiplicativeExpression(n0,n1); } +} + +CastExpression CastExpression() : +{ + NodeChoice n0; + NodeSequence n1; + NodeToken n2; + Token n3; + TypeSpecifier n4; + NodeToken n5; + Token n6; + CastExpression n7; + UnaryExpression n8; + + +} +{ + ( + ( + LOOKAHEAD("(" TypeSpecifier() ")" CastExpression()) + { n1 = new NodeSequence(5); } + n3="(" { n2 = JTBToolkit.makeNodeToken(n3); } + { n1.addNode(n2); } + n4=TypeSpecifier() + { n1.addNode(n4); } + n6=")" { n5 = JTBToolkit.makeNodeToken(n6); } + { n1.addNode(n5); } + n7=CastExpression() + { n1.addNode(n7); } + { n0 = new NodeChoice(n1, 0); } + | + n8=UnaryExpression() + { n0 = new NodeChoice(n8, 1); } + ) + + ) + + { return new CastExpression(n0); } +} + +UnaryExpression UnaryExpression() : +{ + NodeChoice n0; + PostfixExpression n1; + NodeSequence n2; + NodeToken n3; + Token n4; + UnaryExpression n5; + NodeSequence n6; + NodeToken n7; + Token n8; + UnaryExpression n9; + NodeSequence n10; + UnaryOperator n11; + CastExpression n12; + NodeSequence n13; + NodeToken n14; + Token n15; + NodeChoice n16; + UnaryExpression n17; + NodeSequence n18; + NodeToken n19; + Token n20; + TypeSpecifier n21; + NodeToken n22; + Token n23; + + +} +{ + ( + ( + LOOKAHEAD(3) + n1=PostfixExpression() + { n0 = new NodeChoice(n1, 0); } + | + { n2 = new NodeSequence(2); } + n4="++" { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=UnaryExpression() + { n2.addNode(n5); } + { n0 = new NodeChoice(n2, 1); } + | + { n6 = new NodeSequence(2); } + n8="--" { n7 = JTBToolkit.makeNodeToken(n8); } + { n6.addNode(n7); } + n9=UnaryExpression() + { n6.addNode(n9); } + { n0 = new NodeChoice(n6, 2); } + | + { n10 = new NodeSequence(2); } + n11=UnaryOperator() + { n10.addNode(n11); } + n12=CastExpression() + { n10.addNode(n12); } + { n0 = new NodeChoice(n10, 3); } + | + { n13 = new NodeSequence(2); } + n15= { n14 = JTBToolkit.makeNodeToken(n15); } + { n13.addNode(n14); } + ( + ( + LOOKAHEAD(UnaryExpression()) + n17=UnaryExpression() + { n16 = new NodeChoice(n17, 0); } + | + { n18 = new NodeSequence(3); } + n20="(" { n19 = JTBToolkit.makeNodeToken(n20); } + { n18.addNode(n19); } + n21=TypeSpecifier() + { n18.addNode(n21); } + n23=")" { n22 = JTBToolkit.makeNodeToken(n23); } + { n18.addNode(n22); } + { n16 = new NodeChoice(n18, 1); } + ) + + ) + { n13.addNode(n16); } + { n0 = new NodeChoice(n13, 4); } + ) + + ) + + { return new UnaryExpression(n0); } +} + +UnaryOperator UnaryOperator() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + NodeToken n5; + Token n6; + NodeToken n7; + Token n8; + NodeToken n9; + Token n10; + NodeToken n11; + Token n12; + + +} +{ + ( + ( + n2="&" { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n4="*" { n3 = JTBToolkit.makeNodeToken(n4); } + { n0 = new NodeChoice(n3, 1); } + | + n6="+" { n5 = JTBToolkit.makeNodeToken(n6); } + { n0 = new NodeChoice(n5, 2); } + | + n8="-" { n7 = JTBToolkit.makeNodeToken(n8); } + { n0 = new NodeChoice(n7, 3); } + | + n10="~" { n9 = JTBToolkit.makeNodeToken(n10); } + { n0 = new NodeChoice(n9, 4); } + | + n12="!" { n11 = JTBToolkit.makeNodeToken(n12); } + { n0 = new NodeChoice(n11, 5); } + ) + + ) + + { return new UnaryOperator(n0); } +} + +PostfixExpression PostfixExpression() : +{ + PrimaryExpression n0; + NodeListOptional n1 = new NodeListOptional(); + NodeChoice n2; + NodeSequence n3; + NodeToken n4; + Token n5; + Expression n6; + NodeToken n7; + Token n8; + NodeSequence n9; + NodeToken n10; + Token n11; + NodeOptional n12; + ArgumentExpressionList n13; + NodeToken n14; + Token n15; + NodeSequence n16; + NodeToken n17; + Token n18; + NodeToken n19; + Token n20; + NodeSequence n21; + NodeToken n22; + Token n23; + NodeToken n24; + Token n25; + NodeToken n26; + Token n27; + NodeToken n28; + Token n29; + + +} +{ + n0=PrimaryExpression() + ( + { n12 = new NodeOptional(); } + ( + { n3 = new NodeSequence(3); } + n5="[" { n4 = JTBToolkit.makeNodeToken(n5); } + { n3.addNode(n4); } + n6=Expression() + { n3.addNode(n6); } + n8="]" { n7 = JTBToolkit.makeNodeToken(n8); } + { n3.addNode(n7); } + { n2 = new NodeChoice(n3, 0); } + | + { n9 = new NodeSequence(3); } + n11="(" { n10 = JTBToolkit.makeNodeToken(n11); } + { n9.addNode(n10); } + ( + LOOKAHEAD(ArgumentExpressionList()) + n13=ArgumentExpressionList() + { n12.addNode(n13); } + )? + { n9.addNode(n12); } + n15=")" { n14 = JTBToolkit.makeNodeToken(n15); } + { n9.addNode(n14); } + { n2 = new NodeChoice(n9, 1); } + | + { n16 = new NodeSequence(2); } + n18="." { n17 = JTBToolkit.makeNodeToken(n18); } + { n16.addNode(n17); } + n20= { n19 = JTBToolkit.makeNodeToken(n20); } + { n16.addNode(n19); } + { n2 = new NodeChoice(n16, 2); } + | + { n21 = new NodeSequence(2); } + n23="->" { n22 = JTBToolkit.makeNodeToken(n23); } + { n21.addNode(n22); } + n25= { n24 = JTBToolkit.makeNodeToken(n25); } + { n21.addNode(n24); } + { n2 = new NodeChoice(n21, 3); } + | + n27="++" { n26 = JTBToolkit.makeNodeToken(n27); } + { n2 = new NodeChoice(n26, 4); } + | + n29="--" { n28 = JTBToolkit.makeNodeToken(n29); } + { n2 = new NodeChoice(n28, 5); } + ) + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new PostfixExpression(n0,n1); } +} + +PrimaryExpression PrimaryExpression() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + Constant n3; + NodeSequence n4; + NodeToken n5; + Token n6; + Expression n7; + NodeToken n8; + Token n9; + + +} +{ + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n3=Constant() + { n0 = new NodeChoice(n3, 1); } + | + { n4 = new NodeSequence(3); } + n6="(" { n5 = JTBToolkit.makeNodeToken(n6); } + { n4.addNode(n5); } + n7=Expression() + { n4.addNode(n7); } + n9=")" { n8 = JTBToolkit.makeNodeToken(n9); } + { n4.addNode(n8); } + { n0 = new NodeChoice(n4, 2); } + ) + + { return new PrimaryExpression(n0); } +} + +ArgumentExpressionList ArgumentExpressionList() : +{ + AssignmentOrTypeExpression n0; + NodeListOptional n1 = new NodeListOptional(); + NodeSequence n2; + NodeToken n3; + Token n4; + AssignmentOrTypeExpression n5; + + +} +{ + n0=AssignmentOrTypeExpression() + ( + { n2 = new NodeSequence(2); } + n4="," { n3 = JTBToolkit.makeNodeToken(n4); } + { n2.addNode(n3); } + n5=AssignmentOrTypeExpression() + { n2.addNode(n5); } + { n1.addNode(n2); } + )* + { n1.nodes.trimToSize(); } + + { return new ArgumentExpressionList(n0,n1); } +} + +AssignmentOrTypeExpression AssignmentOrTypeExpression() : +{ + NodeChoice n0; + NoIdentifierTypeSpecifier n1; + AssignmentExpression n2; + + +} +{ + ( + n1=NoIdentifierTypeSpecifier() + { n0 = new NodeChoice(n1, 0); } + | + n2=AssignmentExpression() + { n0 = new NodeChoice(n2, 1); } + ) + + { return new AssignmentOrTypeExpression(n0); } +} + +Constant Constant() : +{ + NodeChoice n0; + NodeToken n1; + Token n2; + NodeToken n3; + Token n4; + NodeToken n5; + Token n6; + NodeToken n7; + Token n8; + + +} +{ + ( + n2= { n1 = JTBToolkit.makeNodeToken(n2); } + { n0 = new NodeChoice(n1, 0); } + | + n4= { n3 = JTBToolkit.makeNodeToken(n4); } + { n0 = new NodeChoice(n3, 1); } + | + n6= { n5 = JTBToolkit.makeNodeToken(n6); } + { n0 = new NodeChoice(n5, 2); } + | + n8= { n7 = JTBToolkit.makeNodeToken(n8); } + { n0 = new NodeChoice(n7, 3); } + ) + + { return new Constant(n0); } +} diff --git a/src/monkey/Makefile.am b/src/monkey/Makefile.am index 2f8ca295c..700522dae 100644 --- a/src/monkey/Makefile.am +++ b/src/monkey/Makefile.am @@ -54,33 +54,30 @@ gnunet_service_monkey_LDADD = \ $(GN_LIBINTL) -bug_null_pointer_exception_SOURCES = \ - bug_null_pointer_exception.c -bug_null_pointer_exception_LDADD = \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(GN_LIBINTL) +bug_null_pointer_exception: + gcc -g -O0 -o bug_null_pointer_exception bug_null_pointer_exception.c check_PROGRAMS = \ - bug_null_pointer_exception \ - test_gnunet_monkey + bug_null_pointer_exception + #test_gnunet_monkey if !DISABLE_TEST_RUN # TESTS = $(check_SCRIPTS) endif -test_gnunet_monkey_SOURCES = \ - test_gnunet_monkey.c -test_gnunet_monkey_LDADD = \ - $(top_builddir)/src/arm/libgnunetarm.la \ - $(top_builddir)/src/util/libgnunetutil.la +#test_gnunet_monkey_SOURCES = \ + #test_gnunet_monkey.c +#test_gnunet_monkey_LDADD = \ + #$(top_builddir)/src/arm/libgnunetarm.la \ + #$(top_builddir)/src/util/libgnunetutil.la check_SCRIPTS = \ - test_gnunet_monkey.sh -# test_monkey_npe.sh + #test_gnunet_monkey.sh \ + test_monkey_npe.sh EXTRA_DIST = \ - test_gnunet_monkey_data.conf \ + #test_gnunet_monkey_data.conf \ $(check_SCRIPTS) endif diff --git a/src/monkey/gnunet-monkey.c b/src/monkey/gnunet-monkey.c index d9b651512..ff1317f61 100644 --- a/src/monkey/gnunet-monkey.c +++ b/src/monkey/gnunet-monkey.c @@ -16,8 +16,9 @@ #include "platform.h" #include "gnunet_common.h" - extern void sendMail (const char *messageContents); +static const char* mode; +static const char* dumpFileName; void cb_console(const char *str, void *data) { @@ -54,13 +55,26 @@ void cb_async(mi_output *o, void *data) } +static void dumpText(const char* message) +{ + FILE* file = fopen(dumpFileName, "w"); + GNUNET_assert(NULL != file); + fprintf(file, message); + fclose(file); +} + + void send_bug_mail(mi_stop* sr, mi_frames* f) { char *message; GNUNET_asprintf(&message, "Bug detected in file:%s\nfunction:%s\nline:%d\nreason:%s\nreceived signal:%s\n%s\n", f->file, f->func, f->line, mi_reason_enum_to_str(sr->reason), sr->signal_name, sr->signal_meaning); - sendMail(message); + if (strcasecmp(mode, "mail") == 0) + sendMail(message); + else + dumpText(message); + GNUNET_free (message); } @@ -95,9 +109,33 @@ int main(int argc, char *argv[]) { mi_aux_term *xterm_tty=NULL; const char* binaryName; + const char* argument; + int i = 1; + + argument = argv[i]; + GNUNET_assert(NULL != argument); + do { + if (strcasecmp(argument, "--mode") == 0) { + argument = argv[++i]; + GNUNET_assert(NULL != argument); + mode = argument; + } + else if (strcasecmp(argument, "--binary") == 0) { + argument = argv[++i]; + GNUNET_assert(NULL != argument); + binaryName = argument; + } + else if (strcasecmp(argument, "--output") == 0) { + argument = argv[++i]; + GNUNET_assert(NULL != argument); + dumpFileName = argument; + } + else + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Monkey: Error: Unexpected argument\n")); + } while (NULL != (argument = argv[++i])); + GNUNET_assert((NULL != binaryName) || (NULL != mode)); + GNUNET_assert(!((strcasecmp(mode, "text") == 0) && (NULL == dumpFileName))); - binaryName = argv[1]; - GNUNET_assert(NULL != binaryName); /* This is like a file-handle for fopen. Here we have all the state of gdb "connection". */ diff --git a/src/monkey/test_monkey_npe.sh b/src/monkey/test_monkey_npe.sh index ef611f8fb..c8fa2ceaa 100755 --- a/src/monkey/test_monkey_npe.sh +++ b/src/monkey/test_monkey_npe.sh @@ -1,5 +1,11 @@ #!/bin/sh -./gnunet-monkey --output=npe.out ./bug_null_pointer_exception && exit 1 -grep "null pointer exception on line bug_null_pointer_exception.c:12" npe.out > /dev/null || exit 2 -grep "expression \`nullString\' is NULL" npe.out > /dev/null || exit 2 +echo -n "Test Monkey with Bug - Null Pointer Exception -" +gnunet-monkey --mode text --binary bug_null_pointer_exception --output npe.out && exit 0 +grep "Bug detected in file:bug_null_pointer_exception.c" npe.out > /dev/null || exit 1 +grep "function:crashFunction" npe.out > /dev/null || exit 1 +grep "line:8" npe.out > /dev/null || exit 1 +grep "reason:Signal received" npe.out > /dev/null || exit 1 +grep "received signal:EXC_BAD_ACCESS" npe.out > /dev/null || exit 1 +grep "Could not access memory" npe.out > /dev/null || exit 1 rm -f npe.out +echo "PASS" \ No newline at end of file -- 2.25.1