Contribution:
antlrAcceptor
Headline
An ANTLR-based acceptor for textual syntax
Characteristics
A concrete syntax for companies is defined using the grammar notation of Technology:ANTLR so that a parser can be generated. The underlying grammar is LL(1). Such parsing of concrete syntax is viewed as an instance of Feature:Parsing. However, the resulting implementation does not provide no further operations on companies. Hence, this is an incomplete implementation.
Illustration
The data model is implemented as plain textual files:
A Parser for Feature:Company will be generated by Technology:ANTLR using src/main/antlr/Company.g.
A Company is defined by:
company :
'company' STRING '{' department* '}' EOF;
department :
'department' STRING '{'
('manager' employee)
('employee' employee)*
department*
'}';
employee :
STRING '{'
'address' STRING
'salary' FLOAT
'}';
STRING : '"' (~'"')* '"';
FLOAT : ('0'..'9')+ ('.' ('0'..'9')+)?;
WS : (' '|'\r'? '\n'|'\t')+ {skip();};
Feature:Parsing is implemented using the generated Parser:
public class Parsing {
public static CompanyParser parse(String s)
throws IOException, RecognitionException {
FileInputStream stream = new FileInputStream(s);
ANTLRInputStream antlr = new ANTLRInputStream(stream);
CompanyLexer lexer = new CompanyLexer(antlr);
CommonTokenStream tokens = new CommonTokenStream(lexer);
CompanyParser parser = new CompanyParser(tokens);
parser.company();
if (parser.error) throw new RecognitionException();
return parser;
}
}
Test cases are implemented for all Namespace:Features. There is also an invalid input:
Relationships
For a ANTLR4 version see Contribution:antlr4Acceptor.
For plain syntax checking with Technology:ANTLR see Contribution:antlrAcceptor.
For lexer-based text processing in pure Language:Java see Contribution:javaScanner.
For lexing/tokenization with Technology:ANTLR see Contribution:antlrLexer.
For a custom made lexer in pure Language:Java see Contribution:javaLexer.
For parsing with semantic actions with Technology:ANTLR see Contribution:antlrParser.
For recursive-descent parsing in pure Language:Java] see Contribution:javaParser.
For parser combinators in pure Language:Java] see Contribution:javaParseLib.
For object/text mapping from test to companies with Technology:ANTLR see Contribution:antlrObjects.
For object/text mapping from text to trees with Technology:ANTLR see Contribution:antlrTrees.
Architecture
The contribution follows a standardized structure:
- src/main/antlr contains grammar files for Technology:ANTLR.
- src/main/java contains the following packages:
- org.softlang.company.features for implementations of Functional requirements.
- org.softlang.company.antlr for Technology:ANTLR-generated Java classes (post build).
- src/test/java contains the following packages:
- org.softlang.company.tests for Technology:JUnit test cases.
Usage
This contribution uses Technology:Gradle for building. Technology:Eclipse is supported.
See https://github.com/101companies/101simplejava/blob/master/README.md
Backlinks
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.