Examples of PPParser


Examples of com.puppetlabs.geppetto.pp.dsl.parser.antlr.PPParser

    return resource;

  }

  public IParseResult parseString(ParserRule rule, String s) throws PPSyntaxErrorException {
    PPParser parser = getParser();
    IParseResult result = parser.parse(rule, new StringReader(s));
    if(result.hasSyntaxErrors())
      throw new PPSyntaxErrorException(result);
    return result;
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.parser.antlr.PPParser

  // }

  @Test
  public void test_Parse_LiteralNameOrReference_NotOk() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();
    for(String s : invalidNames) {
      IParseResult result = parser.parse(ga.getUnionNameOrReferenceRule(), new StringReader(s));
      assertTrue("Should have errors for: " + s, result.hasSyntaxErrors());
    }

  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.parser.antlr.PPParser

  }

  @Test
  public void test_Parse_LiteralNameOrReference_Ok() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();
    for(String s : validNames) {
      IParseResult result = parser.parse(ga.getUnionNameOrReferenceRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
    }
    for(String s : validNames) {
      if("class".equals(s))
        continue; // 'class' alone is not a valid value expression
      IParseResult result = parser.parse(ga.getExpressionRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
      EObject root = result.getRootASTElement();
      // if("class".equals(s)) {
      // assertTrue("Should be ResourceExpression", root instanceof ResourceExpression);
      // }
      // else {
      assertTrue("Should be LiteralNameOrReference", root instanceof LiteralNameOrReference);
      assertEquals("Literal should be same as input", s, ((LiteralNameOrReference) root).getValue());
      // }
    }
    for(String s : validNames) {
      if("class".equals(s))
        continue; // 'class' alone is not a balid value expression
      IParseResult result = parser.parse(ga.getPuppetManifestRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
      EObject root = result.getRootASTElement();
      assertTrue("Should be PuppetManifest", root instanceof PuppetManifest);
      PuppetManifest pm = (PuppetManifest) root;
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.parser.antlr.PPParser

  }

  @Test
  public void test_Parse_LiteralsInResource_Smoketest() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();

    String s = "File { mode => 666 }";
    IParseResult result = parser.parse(ga.getPuppetManifestRule(), new StringReader(s));
    assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
    assertEquals("parsed should be same as input", s, result.getRootNode().getText());
    EObject root = result.getRootASTElement();
    assertTrue("Should be PuppetManifest", root instanceof PuppetManifest);
    PuppetManifest pm = (PuppetManifest) root;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.