Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
StringLiteralElement.java
Package: antlr-2_7_0.zip [view]
Upload User: afrynkmhm
Upload Date: 2007-01-06
Package Size: 1262k
Code Size: 2k
Category:
Compiler program
Development Platform:
Others
- package antlr;
- /* ANTLR Translator Generator
- * Project led by Terence Parr at http://www.jGuru.com
- * Software rights: http://www.antlr.org/RIGHTS.html
- *
- * $Id: //depot/code/org.antlr/release/antlr-2.7.0/antlr/StringLiteralElement.java#1 $
- */
- class StringLiteralElement extends GrammarAtom {
- // atomText with quotes stripped and escape codes processed
- protected String processedAtomText;
- public StringLiteralElement(Grammar g, Token t, int autoGenType) {
- super(g, t, autoGenType);
- if (!(g instanceof LexerGrammar)) {
- // lexer does not have token types for string literals
- TokenSymbol ts = grammar.tokenManager.getTokenSymbol(atomText);
- if (ts == null) {
- g.tool.error("Undefined literal: " + atomText, grammar.getFilename(), t.getLine());
- } else {
- tokenType = ts.getTokenType();
- }
- }
- line = t.getLine();
- // process the string literal text by removing quotes and escaping chars
- // If a lexical grammar, add the characters to the char vocabulary
- processedAtomText = new String();
- for (int i = 1; i < atomText.length()-1; i++)
- {
- char c = atomText.charAt(i);
- if (c == '\') {
- if (i+1 < atomText.length()-1) {
- i++;
- c = atomText.charAt(i);
- switch (c) {
- case 'n' : c = 'n'; break;
- case 'r' : c = 'r'; break;
- case 't' : c = 't'; break;
- }
- }
- }
- if (g instanceof LexerGrammar) {
- ((LexerGrammar)g).charVocabulary.add(c);
- }
- processedAtomText += c;
- }
- }
- public void generate() {
- grammar.generator.gen(this);
- }
- public Lookahead look(int k) {
- return grammar.theLLkAnalyzer.look(k, this);
- }
- }