public org.kframework.definition.Bubble apply(StringSentence sentence) { return Bubble(sentence.getType(), sentence.getContent(), convertAttributes(sentence) .add("contentStartLine", Integer.class, sentence.getContentStartLine()) .add("contentStartColumn", Integer.class, sentence.getContentStartColumn())); }
@Override public StringSentence shallowCopy() { return new StringSentence(this); }
/** Parses a given string that was read from 'source' as a list of attributes. Note that the source position in the returned result is relative to the String. */ public static Attributes parseAttributes(String string, Source source) throws ParseException { Outer parser = new Outer(new StringReader(string)); parser.source = source; parser.module = null; parser.items = new ArrayList<DefinitionItem>(); StringSentence ss = new StringSentence("", 0, 0, "", ""); try { parser.AttributesBodyEOF(ss); } catch (TokenMgrError e) { throw new ParseException(e.getMessage()); } return ss.getAttributes(); }
@Test public void testEmptyRules() throws Exception { // TODO: remove once the new parser is fully functional String def = "module TEST rule endmodule"; List<DefinitionItem> defItemList = Outer.parse(Source.apply("generated by OuterParsingTests"), def, null); Module mod = (Module) defItemList.get(0); StringSentence sen = (StringSentence) mod.getItems().get(0); Assert.assertEquals(sen.getContent(), ""); }
parser.beginColumn = offsetLine(str, sentenceBeginLine, sentenceBeginColumn, offset + i); try { StringSentence ss = new StringSentence(content.substring(0, i), startLine, startColumn, type, label); parser.AttributesEOF(ss); return ss; return new StringSentence(content, startLine, startColumn, type, label);