PerlConfiguration getConfiguration() { return new PerlConfiguration(Charset.forName(charsetProperty.getValue())); }
@Test public void getConfiguration_charset() { PerlConfigurationModel model = new PerlConfigurationModel(); model.charsetProperty.setValue("UTF-8"); assertThat(model.getCharset()).isEqualTo(Charsets.UTF_8); assertThat(model.getConfiguration().getCharset()).isEqualTo(Charsets.UTF_8); model.charsetProperty.setValue("ISO-8859-1"); assertThat(model.getCharset()).isEqualTo(Charsets.ISO_8859_1); assertThat(model.getConfiguration().getCharset()).isEqualTo(Charsets.ISO_8859_1); }
public static Lexer create(PerlConfiguration config) { return Lexer.builder() .withCharset(config.getCharset()) .withFailIfNoChannelToConsumeOneCharacter(true) .withChannel(new NewLineChannel()) .withChannel(new BlackHoleChannel("\\s")) .withChannel(commentRegexp("#[^\\n\\r]*+")) .withChannel(new PODChannel()) .withChannel(commentRegexp("__END__[\\n\\r].*+")) .withChannel(commentRegexp("__DATA__[\\n\\r].*+")) .withChannel(new StringLiteralsChannel()) .withChannel(new QuoteLikeChannel()) .withChannel(new HeredocChannel()) .withChannel(regexp(PerlTokenType.NUMBER, "[1-9][0-9]*+[.][0-9]++" + EXP)) .withChannel(regexp(PerlTokenType.NUMBER, "[1-9][0-9]*+[.][0-9]++")) .withChannel(regexp(PerlTokenType.NUMBER, "[1-9][0-9]*+" + EXP)) .withChannel(regexp(PerlTokenType.NUMBER, "[1-9][0-9]*+")) .withChannel(regexp(PerlTokenType.NUMBER, "0++")) .withChannel(new IdentifierAndKeywordChannel(and("[$%&@]?[a-zA-Z_]", o2n("\\w")), true, PerlKeyword.values())) .withChannel(new PunctuatorChannel(PerlPunctuator.values())) .withChannel(new UnknownCharacterChannel()) .build(); } }
public PerlScanner(SensorContext context, List<InputFile> inputFiles) { this.context = context; this.inputFiles = inputFiles; this.parser = PerlParser.create(new PerlConfiguration(context.fileSystem().encoding())); }
@BeforeClass public static void init() { lexer = PerlLexer.create(new PerlConfiguration(StandardCharsets.UTF_8)); }
public static PerlVisitorContext createContext(File file) { Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8)); TestPerlFile perlFile = new TestPerlFile(file); AstNode rootTree = parser.parse(perlFile.content()); return new PerlVisitorContext(rootTree, perlFile); }
public static PerlVisitorContext createContext(File file) { Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8)); TestPerlFile pythonFile = new TestPerlFile(file); AstNode rootTree = parser.parse(pythonFile.content()); return new PerlVisitorContext(rootTree, pythonFile); }