1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-07 00:04:36 +03:00

Applying some Mac build / project patches by Wim Lewis. Simplifying Compiler.java. Removing the preprocessor since it's not actually used for anything. Bumping the version number to 0011.

This commit is contained in:
David A. Mellis
2008-01-19 16:37:19 +00:00
parent bd56d4ff28
commit 3c43daaca8
39 changed files with 176 additions and 40147 deletions

View File

@@ -1,133 +0,0 @@
package processing.app.preproc;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
public class CSymbolTable {
/** holds list of scopes */
private Vector scopeStack;
/** table where all defined names are mapped to TNode tree nodes */
private Hashtable symTable;
public CSymbolTable() {
scopeStack = new Vector(10);
symTable = new Hashtable(533);
}
/** push a new scope onto the scope stack.
*/
public void pushScope(String s) {
//System.out.println("push scope:" + s);
scopeStack.addElement(s);
}
/** pop the last scope off the scope stack.
*/
public void popScope() {
//System.out.println("pop scope");
int size = scopeStack.size();
if(size > 0)
scopeStack.removeElementAt(size - 1);
}
/** return the current scope as a string
*/
public String currentScopeAsString() {
StringBuffer buf = new StringBuffer(100);
boolean first = true;
Enumeration e = scopeStack.elements();
while(e.hasMoreElements()) {
if(first)
first = false;
else
buf.append("::");
buf.append(e.nextElement().toString());
}
return buf.toString();
}
/** given a name for a type, append it with the
current scope.
*/
public String addCurrentScopeToName(String name) {
String currScope = currentScopeAsString();
return addScopeToName(currScope, name);
}
/** given a name for a type, append it with the
given scope. MBZ
*/
public String addScopeToName(String scope, String name) {
if(scope == null || scope.length() > 0)
return scope + "::" + name;
else
return name;
}
/** remove one level of scope from name MBZ*/
public String removeOneLevelScope(String scopeName) {
int index = scopeName.lastIndexOf("::");
if (index > 0) {
return scopeName.substring(0,index);
}
if (scopeName.length() > 0) {
return "";
}
return null;
}
/** add a node to the table with it's key as
the current scope and the name */
public TNode add(String name, TNode node) {
return (TNode)symTable.put(addCurrentScopeToName(name),node);
}
/** lookup a fully scoped name in the symbol table */
public TNode lookupScopedName(String scopedName) {
return (TNode)symTable.get(scopedName);
}
/** lookup an unscoped name in the table by prepending
the current scope.
MBZ -- if not found, pop scopes and look again
*/
public TNode lookupNameInCurrentScope(String name) {
String scope = currentScopeAsString();
String scopedName;
TNode tnode = null;
//System.out.println( "\n"+ this.toString() );
while (tnode == null && scope != null) {
scopedName = addScopeToName(scope, name);
//System.out.println("lookup trying " + scopedName);
tnode = (TNode)symTable.get(scopedName);
scope = removeOneLevelScope(scope);
}
return tnode;
}
/** convert this table to a string */
public String toString() {
StringBuffer buff = new StringBuffer(300);
buff.append("CSymbolTable { \nCurrentScope: " + currentScopeAsString() +
"\nDefinedSymbols:\n");
Enumeration ke = symTable.keys();
Enumeration ve = symTable.elements();
while(ke.hasMoreElements()) {
buff.append(ke.nextElement().toString() + " (" +
TNode.getNameForType(((TNode)ve.nextElement()).getType()) + ")\n");
}
buff.append("}\n");
return buff.toString();
}
};

View File

@@ -1,32 +0,0 @@
package processing.app.preproc;
import antlr.CommonToken;
public class CToken extends antlr.CommonToken {
String source = "";
int tokenNumber;
public String getSource()
{
return source;
}
public void setSource(String src)
{
source = src;
}
public int getTokenNumber()
{
return tokenNumber;
}
public void setTokenNumber(int i)
{
tokenNumber = i;
}
public String toString() {
return "CToken:" +"(" + hashCode() + ")" + "[" + getType() + "] "+ getText() + " line:" + getLine() + " source:" + source ;
}
}

View File

@@ -1,132 +0,0 @@
package antlr;
/* ANTLR Translator Generator
* Project led by Terence Parr at http://www.jGuru.com
* Software rights: http://www.antlr.org/RIGHTS.html
*
* $Id$
*/
import java.io.*;
import antlr.*;
import antlr.collections.*;
import antlr.collections.impl.*;
/** A CommonAST whose initialization copies hidden token
* information from the Token used to create a node.
*/
public class ExtendedCommonASTWithHiddenTokens
extends CommonASTWithHiddenTokens {
public ExtendedCommonASTWithHiddenTokens() {
super();
}
public ExtendedCommonASTWithHiddenTokens(Token tok) {
super(tok);
}
public void initialize(AST ast) {
ExtendedCommonASTWithHiddenTokens a =
(ExtendedCommonASTWithHiddenTokens)ast;
super.initialize(a);
hiddenBefore = a.getHiddenBefore();
hiddenAfter = a.getHiddenAfter();
}
public String getHiddenAfterString() {
CommonHiddenStreamToken t;
StringBuffer hiddenAfterString = new StringBuffer(100);
for ( t = hiddenAfter ; t != null ; t = t.getHiddenAfter() ) {
hiddenAfterString.append(t.getText());
}
return hiddenAfterString.toString();
}
public String getHiddenBeforeString() {
antlr.CommonHiddenStreamToken
child = null,
parent = hiddenBefore;
// if there aren't any hidden tokens here, quietly return
//
if (parent == null) {
return "";
}
// traverse back to the head of the list of tokens before this node
do {
child = parent;
parent = child.getHiddenBefore();
} while (parent != null);
// dump that list
StringBuffer hiddenBeforeString = new StringBuffer(100);
for ( CommonHiddenStreamToken t = child; t != null ;
t = t.getHiddenAfter() ) {
hiddenBeforeString.append(t.getText());
}
return hiddenBeforeString.toString();
}
public void xmlSerializeNode(Writer out)
throws IOException {
StringBuffer buf = new StringBuffer(100);
buf.append("<");
buf.append(getClass().getName() + " ");
buf.append("hiddenBeforeString=\"" +
encode(getHiddenBeforeString()) +
"\" text=\"" + encode(getText()) + "\" type=\"" +
getType() + "\" hiddenAfterString=\"" +
encode(getHiddenAfterString()) + "\"/>");
out.write(buf.toString());
}
public void xmlSerializeRootOpen(Writer out)
throws IOException {
StringBuffer buf = new StringBuffer(100);
buf.append("<");
buf.append(getClass().getName() + " ");
buf.append("hiddenBeforeString=\"" +
encode(getHiddenBeforeString()) +
"\" text=\"" + encode(getText()) + "\" type=\"" +
getType() + "\" hiddenAfterString=\"" +
encode(getHiddenAfterString()) + "\">\n");
out.write(buf.toString());
}
public void xmlSerializeRootClose(Writer out)
throws IOException {
out.write("</" + getClass().getName() + ">\n");
}
public void xmlSerialize(Writer out) throws IOException {
// print out this node and all siblings
for (AST node = this;
node != null;
node = node.getNextSibling()) {
if (node.getFirstChild() == null) {
// print guts (class name, attributes)
((BaseAST)node).xmlSerializeNode(out);
}
else {
((BaseAST)node).xmlSerializeRootOpen(out);
// print children
((BaseAST)node.getFirstChild()).xmlSerialize(out);
// print end tag
((BaseAST)node).xmlSerializeRootClose(out);
}
}
}
}

View File

@@ -1,126 +0,0 @@
package processing.app.preproc;
class LineObject {
LineObject parent = null;
String source = "";
int line = 1;
boolean enteringFile = false;
boolean returningToFile = false;
boolean systemHeader = false;
boolean treatAsC = false;
public LineObject()
{
super();
}
public LineObject( LineObject lobj )
{
parent = lobj.getParent();
source = lobj.getSource();
line = lobj.getLine();
enteringFile = lobj.getEnteringFile();
returningToFile = lobj.getReturningToFile();
systemHeader = lobj.getSystemHeader();
treatAsC = lobj.getTreatAsC();
}
public LineObject( String src)
{
source = src;
}
public void setSource(String src)
{
source = src;
}
public String getSource()
{
return source;
}
public void setParent(LineObject par)
{
parent = par;
}
public LineObject getParent()
{
return parent;
}
public void setLine(int l)
{
line = l;
}
public int getLine()
{
return line;
}
public void newline()
{
line++;
}
public void setEnteringFile(boolean v)
{
enteringFile = v;
}
public boolean getEnteringFile()
{
return enteringFile;
}
public void setReturningToFile(boolean v)
{
returningToFile = v;
}
public boolean getReturningToFile()
{
return returningToFile;
}
public void setSystemHeader(boolean v)
{
systemHeader = v;
}
public boolean getSystemHeader()
{
return systemHeader;
}
public void setTreatAsC(boolean v)
{
treatAsC = v;
}
public boolean getTreatAsC()
{
return treatAsC;
}
public String toString() {
StringBuffer ret;
ret = new StringBuffer("# " + line + " \"" + source + "\"");
if (enteringFile) {
ret.append(" 1");
}
if (returningToFile) {
ret.append(" 2");
}
if (systemHeader) {
ret.append(" 3");
}
if (treatAsC) {
ret.append(" 4");
}
return ret.toString();
}
}

View File

@@ -1,36 +0,0 @@
classfiles = LineObject.class PreprocessorInfoChannel.class StdCParser.class StdCLexer.class WParser.class WLexer.class WTreeParser.class WEmitter.class
javafiles = CSymbolTable.java TNode.java TNodeFactory.java CToken.java LineObject.java PreprocessorInfoChannel.java StdCParser.java StdCLexer.java WParser.java WLexer.java WTreeParser.java WEmitter.java
all : $(javafiles) $(classfiles)
clean :
StdCParser.java StdCLexer.java : StdCParser.g
java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool StdCParser.g
WParser.java WLexer.java : WParser.g WParser.g
java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool -glib "StdCParser.g" WParser.g
WTreeParser.java : WTreeParser.g
java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool WTreeParser.g
WEmitter.java : WEmitter.g WTreeParser.g
java -cp "..\\..\\build\\windows\\work\\lib\\antlr.jar" antlr.Tool -glib "WTreeParser.g" WEmitter.g
.SUFFIXES: .java .class
.java.class :
../../build/windows/work/jikes -cp "..\\..\\build\\windows\\work\\java\\lib\\rt.jar;..\\..\\build\\windows\\work\\lib\\mrj.jar;..\\..\\build\\windows\\work\\lib\\antlr.jar;." $<

View File

@@ -256,10 +256,10 @@ public class PdePreprocessor {
// match those that will be highlighted in the PDE IDE
//
//System.out.println(program);
WLexer lexer = new WLexer(programReader);
// DAM:WTF? WLexer lexer = new WLexer(programReader);
//lexer.setTokenObjectClass("antlr.CommonHiddenStreamToken");
lexer.setTokenObjectClass("processing.app.preproc.CToken");
lexer.initialize();
// DAM:WTF? lexer.setTokenObjectClass("processing.app.preproc.CToken");
// DAM:WTF? lexer.initialize();
// create the filter for hidden tokens and specify which tokens to
// hide and which to copy to the hidden text
@@ -281,13 +281,13 @@ public class PdePreprocessor {
// create a parser and set what sort of AST should be generated
//
//PdeRecognizer parser = new PdeRecognizer(filter);
WParser parser = new WParser(lexer);
// DAM:WTF? WParser parser = new WParser(lexer);
// use our extended AST class
//
//parser.setASTNodeClass("antlr.ExtendedCommonASTWithHiddenTokens");
parser.setASTNodeType(TNode.class.getName());
TNode.setTokenVocabulary("processing.app.preproc.WTokenTypes");
// DAM:WTF? parser.setASTNodeType(TNode.class.getName());
// DAM:WTF? TNode.setTokenVocabulary("processing.app.preproc.WTokenTypes");
// start parsing at the compilationUnit non-terminal
//
@@ -296,23 +296,23 @@ public class PdePreprocessor {
// set up the AST for traversal by PdeEmitter
//
ASTFactory factory = new ASTFactory();
AST parserAST = parser.getAST();
AST rootNode = factory.create(ROOT_ID, "AST ROOT");
rootNode.setFirstChild(parserAST);
// DAM:WTF? ASTFactory factory = new ASTFactory();
// DAM:WTF? AST parserAST = parser.getAST();
// DAM:WTF? AST rootNode = factory.create(ROOT_ID, "AST ROOT");
// DAM:WTF? rootNode.setFirstChild(parserAST);
// unclear if this actually works, but it's worth a shot
//
//((CommonAST)parserAST).setVerboseStringConversion(
// true, parser.getTokenNames());
// (made to use the static version because of jikes 1.22 warning)
CommonAST.setVerboseStringConversion(true, parser.getTokenNames());
// DAM:WTF? CommonAST.setVerboseStringConversion(true, parser.getTokenNames());
// if this is an advanced program, the classname is already defined.
//
if (programType == JAVA) {
name = getFirstClassName(parserAST);
}
// DAM:WTF? if (programType == JAVA) {
// DAM:WTF? name = getFirstClassName(parserAST);
// DAM:WTF? }
// if 'null' was passed in for the name, but this isn't
// a 'java' mode class, then there's a problem, so punt.
@@ -321,7 +321,7 @@ public class PdePreprocessor {
// output the code
//
WEmitter emitter = new WEmitter(lexer.getPreprocessorInfoChannel());
// DAM:WTF? WEmitter emitter = new WEmitter(lexer.getPreprocessorInfoChannel());
File streamFile = new File(buildPath, name + ".cpp");
PrintStream stream = new PrintStream(new FileOutputStream(streamFile));
@@ -329,8 +329,8 @@ public class PdePreprocessor {
writeHeader(stream, name, prototypes);
//added to write the pde code to the cpp file
writeProgram(stream, name, program);
emitter.setASTNodeType(TNode.class.getName());
emitter.setOut(stream);
// DAM:WTF? emitter.setASTNodeType(TNode.class.getName());
// DAM:WTF? emitter.setOut(stream);
//emitter.printDeclarations(rootNode);
//emitter.print(rootNode);
//emitter.translationUnit(parser.getAST());
@@ -340,7 +340,7 @@ public class PdePreprocessor {
// if desired, serialize the parse tree to an XML file. can
// be viewed usefully with Mozilla or IE
/* DAM:WTF?
if (Preferences.getBoolean("preproc.output_parse_tree")) {
stream = new PrintStream(new FileOutputStream("parseTree.xml"));
@@ -354,6 +354,7 @@ public class PdePreprocessor {
stream.println("</document>");
writer.close();
}
*/
return name;
}

View File

@@ -1,73 +0,0 @@
package processing.app.preproc;
import java.util.*;
public class PreprocessorInfoChannel
{
Hashtable lineLists = new Hashtable(); // indexed by Token number
int firstValidTokenNumber = 0;
int maxTokenNumber = 0;
public void addLineForTokenNumber( Object line, Integer toknum )
{
if ( lineLists.containsKey( toknum ) ) {
Vector lines = (Vector) lineLists.get( toknum );
lines.addElement(line);
}
else {
Vector lines = new Vector();
lines.addElement(line);
lineLists.put(toknum, lines);
if ( maxTokenNumber < toknum.intValue() ) {
maxTokenNumber = toknum.intValue();
}
}
}
public int getMaxTokenNumber()
{
return maxTokenNumber;
}
public Vector extractLinesPrecedingTokenNumber( Integer toknum )
{
Vector lines = new Vector();
if (toknum == null) return lines;
for (int i = firstValidTokenNumber; i < toknum.intValue(); i++){
Integer inti = new Integer(i);
if ( lineLists.containsKey( inti ) ) {
Vector tokenLineVector = (Vector) lineLists.get( inti );
if ( tokenLineVector != null) {
Enumeration tokenLines = tokenLineVector.elements();
while ( tokenLines.hasMoreElements() ) {
lines.addElement( tokenLines.nextElement() );
}
lineLists.remove(inti);
}
}
}
firstValidTokenNumber = toknum.intValue();
return lines;
}
public String toString()
{
StringBuffer sb = new StringBuffer("PreprocessorInfoChannel:\n");
for (int i = 0; i <= maxTokenNumber + 1; i++){
Integer inti = new Integer(i);
if ( lineLists.containsKey( inti ) ) {
Vector tokenLineVector = (Vector) lineLists.get( inti );
if ( tokenLineVector != null) {
Enumeration tokenLines = tokenLineVector.elements();
while ( tokenLines.hasMoreElements() ) {
sb.append(inti + ":" + tokenLines.nextElement() + '\n');
}
}
}
}
return sb.toString();
}
}

View File

@@ -1,149 +0,0 @@
// $ANTLR 2.7.2: "StdCParser.g" -> "StdCLexer.java"$
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
public interface STDCTokenTypes {
int EOF = 1;
int NULL_TREE_LOOKAHEAD = 3;
int LITERAL_typedef = 4;
int LITERAL_asm = 5;
int LITERAL_volatile = 6;
int LCURLY = 7;
int RCURLY = 8;
int SEMI = 9;
int LITERAL_struct = 10;
int LITERAL_union = 11;
int LITERAL_enum = 12;
int LITERAL_auto = 13;
int LITERAL_register = 14;
int LITERAL_extern = 15;
int LITERAL_static = 16;
int LITERAL_const = 17;
int LITERAL_void = 18;
int LITERAL_char = 19;
int LITERAL_short = 20;
int LITERAL_int = 21;
int LITERAL_long = 22;
int LITERAL_float = 23;
int LITERAL_double = 24;
int LITERAL_signed = 25;
int LITERAL_unsigned = 26;
int ID = 27;
int COMMA = 28;
int COLON = 29;
int ASSIGN = 30;
int STAR = 31;
int LPAREN = 32;
int RPAREN = 33;
int LBRACKET = 34;
int RBRACKET = 35;
int VARARGS = 36;
int LITERAL_while = 37;
int LITERAL_do = 38;
int LITERAL_for = 39;
int LITERAL_goto = 40;
int LITERAL_continue = 41;
int LITERAL_break = 42;
int LITERAL_return = 43;
int LITERAL_case = 44;
int LITERAL_default = 45;
int LITERAL_if = 46;
int LITERAL_else = 47;
int LITERAL_switch = 48;
int DIV_ASSIGN = 49;
int PLUS_ASSIGN = 50;
int MINUS_ASSIGN = 51;
int STAR_ASSIGN = 52;
int MOD_ASSIGN = 53;
int RSHIFT_ASSIGN = 54;
int LSHIFT_ASSIGN = 55;
int BAND_ASSIGN = 56;
int BOR_ASSIGN = 57;
int BXOR_ASSIGN = 58;
int QUESTION = 59;
int LOR = 60;
int LAND = 61;
int BOR = 62;
int BXOR = 63;
int BAND = 64;
int EQUAL = 65;
int NOT_EQUAL = 66;
int LT = 67;
int LTE = 68;
int GT = 69;
int GTE = 70;
int LSHIFT = 71;
int RSHIFT = 72;
int PLUS = 73;
int MINUS = 74;
int DIV = 75;
int MOD = 76;
int INC = 77;
int DEC = 78;
int LITERAL_sizeof = 79;
int BNOT = 80;
int LNOT = 81;
int PTR = 82;
int DOT = 83;
int CharLiteral = 84;
int StringLiteral = 85;
int IntOctalConst = 86;
int LongOctalConst = 87;
int UnsignedOctalConst = 88;
int IntIntConst = 89;
int LongIntConst = 90;
int UnsignedIntConst = 91;
int IntHexConst = 92;
int LongHexConst = 93;
int UnsignedHexConst = 94;
int FloatDoubleConst = 95;
int DoubleDoubleConst = 96;
int LongDoubleConst = 97;
int NTypedefName = 98;
int NInitDecl = 99;
int NDeclarator = 100;
int NStructDeclarator = 101;
int NDeclaration = 102;
int NCast = 103;
int NPointerGroup = 104;
int NExpressionGroup = 105;
int NFunctionCallArgs = 106;
int NNonemptyAbstractDeclarator = 107;
int NInitializer = 108;
int NStatementExpr = 109;
int NEmptyExpression = 110;
int NParameterTypeList = 111;
int NFunctionDef = 112;
int NCompoundStatement = 113;
int NParameterDeclaration = 114;
int NCommaExpr = 115;
int NUnaryExpr = 116;
int NLabel = 117;
int NPostfixExpr = 118;
int NRangeExpr = 119;
int NStringSeq = 120;
int NInitializerElementLabel = 121;
int NLcurlyInitializer = 122;
int NAsmAttribute = 123;
int NGnuAsmExpr = 124;
int NTypeMissing = 125;
int Vocabulary = 126;
int Whitespace = 127;
int Comment = 128;
int CPPComment = 129;
int PREPROC_DIRECTIVE = 130;
int Space = 131;
int LineDirective = 132;
int BadStringLiteral = 133;
int Escape = 134;
int Digit = 135;
int LongSuffix = 136;
int UnsignedSuffix = 137;
int FloatSuffix = 138;
int Exponent = 139;
int Number = 140;
}

View File

@@ -1,139 +0,0 @@
// $ANTLR 2.7.2: StdCParser.g -> STDCTokenTypes.txt$
STDC // output token vocab name
LITERAL_typedef="typedef"=4
LITERAL_asm="asm"=5
LITERAL_volatile="volatile"=6
LCURLY=7
RCURLY=8
SEMI=9
LITERAL_struct="struct"=10
LITERAL_union="union"=11
LITERAL_enum="enum"=12
LITERAL_auto="auto"=13
LITERAL_register="register"=14
LITERAL_extern="extern"=15
LITERAL_static="static"=16
LITERAL_const="const"=17
LITERAL_void="void"=18
LITERAL_char="char"=19
LITERAL_short="short"=20
LITERAL_int="int"=21
LITERAL_long="long"=22
LITERAL_float="float"=23
LITERAL_double="double"=24
LITERAL_signed="signed"=25
LITERAL_unsigned="unsigned"=26
ID=27
COMMA=28
COLON=29
ASSIGN=30
STAR=31
LPAREN=32
RPAREN=33
LBRACKET=34
RBRACKET=35
VARARGS=36
LITERAL_while="while"=37
LITERAL_do="do"=38
LITERAL_for="for"=39
LITERAL_goto="goto"=40
LITERAL_continue="continue"=41
LITERAL_break="break"=42
LITERAL_return="return"=43
LITERAL_case="case"=44
LITERAL_default="default"=45
LITERAL_if="if"=46
LITERAL_else="else"=47
LITERAL_switch="switch"=48
DIV_ASSIGN=49
PLUS_ASSIGN=50
MINUS_ASSIGN=51
STAR_ASSIGN=52
MOD_ASSIGN=53
RSHIFT_ASSIGN=54
LSHIFT_ASSIGN=55
BAND_ASSIGN=56
BOR_ASSIGN=57
BXOR_ASSIGN=58
QUESTION=59
LOR=60
LAND=61
BOR=62
BXOR=63
BAND=64
EQUAL=65
NOT_EQUAL=66
LT=67
LTE=68
GT=69
GTE=70
LSHIFT=71
RSHIFT=72
PLUS=73
MINUS=74
DIV=75
MOD=76
INC=77
DEC=78
LITERAL_sizeof="sizeof"=79
BNOT=80
LNOT=81
PTR=82
DOT=83
CharLiteral=84
StringLiteral=85
IntOctalConst=86
LongOctalConst=87
UnsignedOctalConst=88
IntIntConst=89
LongIntConst=90
UnsignedIntConst=91
IntHexConst=92
LongHexConst=93
UnsignedHexConst=94
FloatDoubleConst=95
DoubleDoubleConst=96
LongDoubleConst=97
NTypedefName=98
NInitDecl=99
NDeclarator=100
NStructDeclarator=101
NDeclaration=102
NCast=103
NPointerGroup=104
NExpressionGroup=105
NFunctionCallArgs=106
NNonemptyAbstractDeclarator=107
NInitializer=108
NStatementExpr=109
NEmptyExpression=110
NParameterTypeList=111
NFunctionDef=112
NCompoundStatement=113
NParameterDeclaration=114
NCommaExpr=115
NUnaryExpr=116
NLabel=117
NPostfixExpr=118
NRangeExpr=119
NStringSeq=120
NInitializerElementLabel=121
NLcurlyInitializer=122
NAsmAttribute=123
NGnuAsmExpr=124
NTypeMissing=125
Vocabulary=126
Whitespace=127
Comment=128
CPPComment=129
PREPROC_DIRECTIVE("a line directive")=130
Space=131
LineDirective=132
BadStringLiteral=133
Escape=134
Digit=135
LongSuffix=136
UnsignedSuffix=137
FloatSuffix=138
Exponent=139
Number=140

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,434 +0,0 @@
package processing.app.preproc;
import antlr.collections.AST;
import antlr.CommonAST;
import antlr.Token;
import java.lang.reflect.*;
import java.util.Hashtable;
import java.util.Enumeration;
//import CToken;
/**
Class TNode is an implementation of the AST interface
and adds many useful features:
It is double-linked for reverse searching.
(this is currently incomplete, in that method doubleLink() must
be called after any changes to the tree to maintain the
reverse links).
It can store a definition node (defNode), so that nodes such
as scoped names can refer to the node that defines the name.
It stores line numbers for nodes.
Searches for parents and children of a tree can be done
based on their type.
The tree can be printed to System.out using a lisp-style syntax.
*/
public class TNode extends CommonAST {
protected int ttype;
protected String text;
protected int lineNum = 0;
protected TNode defNode;
protected TNode up;
protected TNode left;
protected boolean marker = false;
protected Hashtable attributes = null;
static String tokenVocabulary;
/** Set the token vocabulary to a tokentypes class
generated by antlr.
*/
public static void setTokenVocabulary(String s) {
tokenVocabulary = s;
}
public void initialize(Token token) {
CToken tok = (CToken) token;
setText(tok.getText());
setType(tok.getType());
setLineNum(tok.getLine());
setAttribute("source", tok.getSource());
setAttribute("tokenNumber", new Integer(tok.getTokenNumber()));
}
public void initialize(AST tr) {
TNode t = (TNode) tr;
setText(t.getText());
setType(t.getType());
setLineNum(t.getLineNum());
setDefNode(t.getDefNode());
this.attributes = t.getAttributesTable();
}
/** Get the token type for this node */
public int getType() { return ttype; }
/** Set the token type for this node */
public void setType(int ttype_) {
ttype = ttype_;
}
/** Get the marker value for this node.
This member is a general-use marker.
*/
public boolean getMarker() { return marker; }
/** Set the marker value for this node.
This property is a general-use boolean marker.
*/
public void setMarker(boolean marker_) {
marker = marker_;
}
/** get the hashtable that holds attribute values.
*/
public Hashtable getAttributesTable() {
if(attributes == null)
attributes = new Hashtable(7);
return attributes;
}
/** set an attribute in the attribute table.
*/
public void setAttribute(String attrName, Object value) {
if(attributes == null)
attributes = new Hashtable(7);
attributes.put(attrName,value);
}
/** lookup the attribute name in the attribute table.
If the value does not exist, it returns null.
*/
public Object getAttribute(String attrName) {
if(attributes == null)
return null;
else
return attributes.get(attrName);
}
/** Get the line number for this node.
If the line number is 0, search for a non-zero line num among children */
public int getLineNum() {
if(lineNum != 0)
return lineNum;
else
if(down == null)
return lineNum;
else
return ((TNode)down).getLocalLineNum();
}
public int getLocalLineNum() {
if(lineNum != 0)
return lineNum;
else
if(down == null)
if(right == null)
return lineNum;
else
return ((TNode)right).getLocalLineNum();
else
return ((TNode)down).getLocalLineNum();
}
/** Set the line number for this node */
public void setLineNum(int lineNum_) {
lineNum = lineNum_;
}
/** Get the token text for this node */
public String getText() { return text; }
/** Set the token text for this node */
public void setText(String text_) {
text = text_;
}
/** return the last child of this node, or null if there is none */
public TNode getLastChild() {
TNode down = (TNode)getFirstChild();
if(down != null)
return down.getLastSibling();
else
return null;
}
/** return the last sibling of this node, which is
this if the next sibling is null */
public TNode getLastSibling() {
TNode next = (TNode)getNextSibling();
if(next != null)
return next.getLastSibling();
else
return this;
}
/** return the first sibling of this node, which is
this if the prev sibling is null */
public TNode getFirstSibling() {
TNode prev = (TNode)left;
if(prev != null)
return prev.getFirstSibling();
else
return this;
}
/** return the parent node of this node */
public TNode getParent() {
return (TNode)getFirstSibling().up;
}
/** add the new node as a new sibling, inserting it ahead of any
existing next sibling. This method maintains double-linking.
if node is null, nothing happens. If the node has siblings,
then they are added in as well.
*/
public void addSibling(AST node) {
if(node == null) return;
TNode next = (TNode)right;
right = (TNode)node;
((TNode)node).left = this;
TNode nodeLastSib = ((TNode)node).getLastSibling();
nodeLastSib.right = next;
if(next != null)
next.left = nodeLastSib;
}
/** return the number of children of this node */
public int numberOfChildren() {
int count = 0;
AST child = getFirstChild();
while(child != null) {
count++;
child = child.getNextSibling();
}
return count;
}
/** remove this node from the tree, resetting sibling and parent
pointers as necessary. This method maintains double-linking */
public void removeSelf() {
TNode parent = (TNode)up;
TNode prev = (TNode)left;
TNode next = (TNode)right;
if(parent != null) {
parent.down = next;
if(next != null) {
next.up = parent;
next.left = prev; // which should be null
}
}
else {
if(prev != null)
prev.right = next;
if(next != null)
next.left = prev;
}
}
/** return the def node for this node */
public TNode getDefNode() {
return defNode;
}
/** set the def node for this node */
public void setDefNode(TNode n) {
defNode = n;
}
/** return a deep copy of this node, and all sub nodes.
New tree is doubleLinked, with no parent or siblings.
Marker value is not copied!
*/
public TNode deepCopy() {
TNode copy = new TNode();
copy.ttype = ttype;
copy.text = text;
copy.lineNum = lineNum;
copy.defNode = defNode;
if(attributes != null)
copy.attributes = (Hashtable)attributes.clone();
if(down != null)
copy.down = ((TNode)down).deepCopyWithRightSiblings();
copy.doubleLink();
return copy;
}
/** return a deep copy of this node, all sub nodes,
and right siblings.
New tree is doubleLinked, with no parent or left siblings.
defNode is not copied */
public TNode deepCopyWithRightSiblings() {
TNode copy = new TNode();
copy.ttype = ttype;
copy.text = text;
copy.lineNum = lineNum;
copy.defNode = defNode;
if(attributes != null)
copy.attributes = (Hashtable)attributes.clone();
if(down != null)
copy.down = ((TNode)down).deepCopyWithRightSiblings();
if(right != null)
copy.right = ((TNode)right).deepCopyWithRightSiblings();
copy.doubleLink();
return copy;
}
/** return a short string representation of the node */
public String toString() {
StringBuffer str = new StringBuffer( getNameForType(getType()) +
"[" + getText() + ", " + "]");
if(this.getLineNum() != 0)
str.append(" line:" + (this.getLineNum() ) );
Enumeration keys = (this.getAttributesTable().keys());
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
str.append(" " + key + ":" + (this.getAttribute(key)));
}
return str.toString();
}
/** print given tree to System.out */
public static void printTree(AST t) {
if (t == null) return;
printASTNode(t,0);
System.out.print("\n");
}
/** protected method that does the work of printing */
protected static void printASTNode(AST t, int indent) {
AST child1, next;
child1 = t.getFirstChild();
System.out.print("\n");
for(int i = 0; i < indent; i++)
System.out.print(" ");
if(child1 != null)
System.out.print("(");
String s = t.getText();
if(s != null && s.length() > 0) {
System.out.print(getNameForType(t.getType()));
System.out.print(": \"" + s + "\"");
}
else
System.out.print(getNameForType(t.getType()));
if(((TNode)t).getLineNum() != 0)
System.out.print(" line:" + ((TNode)t).getLineNum() );
Enumeration keys = ((TNode)t).getAttributesTable().keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
System.out.print(" " + key + ":" + ((TNode)t).getAttribute(key));
}
TNode def = ((TNode)t).getDefNode();
if(def != null)
System.out.print("[" + getNameForType(def.getType()) + "]");
if(child1 != null) {
printASTNode(child1,indent + 1);
System.out.print("\n");
for(int i = 0; i < indent; i++)
System.out.print(" ");
System.out.print(")");
}
next = t.getNextSibling();
if(next != null) {
printASTNode(next,indent);
}
}
/** converts an int tree token type to a name.
Does this by reflecting on nsdidl.IDLTreeTokenTypes,
and is dependent on how ANTLR 2.00 outputs that class. */
public static String getNameForType(int t) {
try{
Class c = Class.forName(tokenVocabulary);
Field[] fields = c.getDeclaredFields();
if(t-2 < fields.length)
return fields[t-2].getName();
} catch (Exception e) { System.out.println(e); }
return "unfoundtype: " + t;
}
/** set up reverse links between this node and its first
child and its first sibling, and link those as well */
public void doubleLink() {
TNode right = (TNode)getNextSibling();
if(right != null) {
right.left = this;
right.doubleLink();
}
TNode down = (TNode)getFirstChild();
if(down != null) {
down.up = this;
down.doubleLink();
}
}
/** find first parent of the given type,
return null on failure */
public TNode parentOfType(int type) {
if(up == null) {
if(left == null)
return null;
else
return left.parentOfType(type);
}
if(up.getType() == type)
return up;
return up.parentOfType(type);
}
/** find the first child of the node
of the given type, return null on failure */
public TNode firstChildOfType(int type) {
TNode down = (TNode)getFirstChild();
if(down == null)
return null;
if(down.getType() == type)
return down;
return down.firstSiblingOfType(type);
}
/** find the first sibling of the node
of the given type, return null on failure */
public TNode firstSiblingOfType(int type) {
TNode right = (TNode)getNextSibling();
if(right == null)
return null;
if(right.getType() == type)
return right;
return right.firstSiblingOfType(type);
}
}

View File

@@ -1,33 +0,0 @@
package processing.app.preproc;
import antlr.Token;
import antlr.ASTFactory;
import antlr.collections.AST;
/** This class extends ASTFactory to build instances
of class TNode */
public class TNodeFactory extends ASTFactory {
/** Create a new ampty AST node */
public AST create() {
return new TNode();
}
/** Create a new AST node from type and text */
public AST create(int ttype, String text) {
AST ast = new TNode();
ast.setType(ttype);
ast.setText(text);
return ast;
}
/** Create a new AST node from an existing AST node */
public AST create(AST ast) {
AST newast = new TNode();
newast.setType(ast.getType());
newast.setText(ast.getText());
return newast;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,163 +0,0 @@
// $ANTLR 2.7.2: "expandedWEmitter.g" -> "WEmitter.java"$
package processing.app.preproc;
import processing.app.*;
import java.io.*;
import java.util.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
public interface WEmitterTokenTypes {
int EOF = 1;
int NULL_TREE_LOOKAHEAD = 3;
int LITERAL_typedef = 4;
int LITERAL_asm = 5;
int LITERAL_volatile = 6;
int LCURLY = 7;
int RCURLY = 8;
int SEMI = 9;
int LITERAL_struct = 10;
int LITERAL_union = 11;
int LITERAL_enum = 12;
int LITERAL_auto = 13;
int LITERAL_register = 14;
int LITERAL_extern = 15;
int LITERAL_static = 16;
int LITERAL_const = 17;
int LITERAL_void = 18;
int LITERAL_char = 19;
int LITERAL_short = 20;
int LITERAL_int = 21;
int LITERAL_long = 22;
int LITERAL_float = 23;
int LITERAL_double = 24;
int LITERAL_signed = 25;
int LITERAL_unsigned = 26;
int ID = 27;
int COMMA = 28;
int COLON = 29;
int ASSIGN = 30;
int STAR = 31;
int LPAREN = 32;
int RPAREN = 33;
int LBRACKET = 34;
int RBRACKET = 35;
int VARARGS = 36;
int LITERAL_while = 37;
int LITERAL_do = 38;
int LITERAL_for = 39;
int LITERAL_goto = 40;
int LITERAL_continue = 41;
int LITERAL_break = 42;
int LITERAL_return = 43;
int LITERAL_case = 44;
int LITERAL_default = 45;
int LITERAL_if = 46;
int LITERAL_else = 47;
int LITERAL_switch = 48;
int DIV_ASSIGN = 49;
int PLUS_ASSIGN = 50;
int MINUS_ASSIGN = 51;
int STAR_ASSIGN = 52;
int MOD_ASSIGN = 53;
int RSHIFT_ASSIGN = 54;
int LSHIFT_ASSIGN = 55;
int BAND_ASSIGN = 56;
int BOR_ASSIGN = 57;
int BXOR_ASSIGN = 58;
int QUESTION = 59;
int LOR = 60;
int LAND = 61;
int BOR = 62;
int BXOR = 63;
int BAND = 64;
int EQUAL = 65;
int NOT_EQUAL = 66;
int LT = 67;
int LTE = 68;
int GT = 69;
int GTE = 70;
int LSHIFT = 71;
int RSHIFT = 72;
int PLUS = 73;
int MINUS = 74;
int DIV = 75;
int MOD = 76;
int INC = 77;
int DEC = 78;
int LITERAL_sizeof = 79;
int BNOT = 80;
int LNOT = 81;
int PTR = 82;
int DOT = 83;
int CharLiteral = 84;
int StringLiteral = 85;
int IntOctalConst = 86;
int LongOctalConst = 87;
int UnsignedOctalConst = 88;
int IntIntConst = 89;
int LongIntConst = 90;
int UnsignedIntConst = 91;
int IntHexConst = 92;
int LongHexConst = 93;
int UnsignedHexConst = 94;
int FloatDoubleConst = 95;
int DoubleDoubleConst = 96;
int LongDoubleConst = 97;
int NTypedefName = 98;
int NInitDecl = 99;
int NDeclarator = 100;
int NStructDeclarator = 101;
int NDeclaration = 102;
int NCast = 103;
int NPointerGroup = 104;
int NExpressionGroup = 105;
int NFunctionCallArgs = 106;
int NNonemptyAbstractDeclarator = 107;
int NInitializer = 108;
int NStatementExpr = 109;
int NEmptyExpression = 110;
int NParameterTypeList = 111;
int NFunctionDef = 112;
int NCompoundStatement = 113;
int NParameterDeclaration = 114;
int NCommaExpr = 115;
int NUnaryExpr = 116;
int NLabel = 117;
int NPostfixExpr = 118;
int NRangeExpr = 119;
int NStringSeq = 120;
int NInitializerElementLabel = 121;
int NLcurlyInitializer = 122;
int NAsmAttribute = 123;
int NGnuAsmExpr = 124;
int NTypeMissing = 125;
int Vocabulary = 126;
int Whitespace = 127;
int Comment = 128;
int CPPComment = 129;
int PREPROC_DIRECTIVE = 130;
int Space = 131;
int LineDirective = 132;
int BadStringLiteral = 133;
int Escape = 134;
int Digit = 135;
int LongSuffix = 136;
int UnsignedSuffix = 137;
int FloatSuffix = 138;
int Exponent = 139;
int Number = 140;
int LITERAL___label__ = 141;
int LITERAL_inline = 142;
int LITERAL_byte = 143;
int LITERAL_boolean = 144;
int LITERAL_Servo = 145;
int LITERAL_Wire = 146;
int LITERAL_typeof = 147;
int LITERAL___complex = 148;
int LITERAL___attribute = 149;
int LITERAL___alignof = 150;
int LITERAL___real = 151;
int LITERAL___imag = 152;
}

View File

@@ -1,151 +0,0 @@
// $ANTLR 2.7.2: expandedWEmitter.g -> WEmitterTokenTypes.txt$
WEmitter // output token vocab name
LITERAL_typedef="typedef"=4
LITERAL_asm="asm"=5
LITERAL_volatile="volatile"=6
LCURLY=7
RCURLY=8
SEMI=9
LITERAL_struct="struct"=10
LITERAL_union="union"=11
LITERAL_enum="enum"=12
LITERAL_auto="auto"=13
LITERAL_register="register"=14
LITERAL_extern="extern"=15
LITERAL_static="static"=16
LITERAL_const="const"=17
LITERAL_void="void"=18
LITERAL_char="char"=19
LITERAL_short="short"=20
LITERAL_int="int"=21
LITERAL_long="long"=22
LITERAL_float="float"=23
LITERAL_double="double"=24
LITERAL_signed="signed"=25
LITERAL_unsigned="unsigned"=26
ID=27
COMMA=28
COLON=29
ASSIGN=30
STAR=31
LPAREN=32
RPAREN=33
LBRACKET=34
RBRACKET=35
VARARGS=36
LITERAL_while="while"=37
LITERAL_do="do"=38
LITERAL_for="for"=39
LITERAL_goto="goto"=40
LITERAL_continue="continue"=41
LITERAL_break="break"=42
LITERAL_return="return"=43
LITERAL_case="case"=44
LITERAL_default="default"=45
LITERAL_if="if"=46
LITERAL_else="else"=47
LITERAL_switch="switch"=48
DIV_ASSIGN=49
PLUS_ASSIGN=50
MINUS_ASSIGN=51
STAR_ASSIGN=52
MOD_ASSIGN=53
RSHIFT_ASSIGN=54
LSHIFT_ASSIGN=55
BAND_ASSIGN=56
BOR_ASSIGN=57
BXOR_ASSIGN=58
QUESTION=59
LOR=60
LAND=61
BOR=62
BXOR=63
BAND=64
EQUAL=65
NOT_EQUAL=66
LT=67
LTE=68
GT=69
GTE=70
LSHIFT=71
RSHIFT=72
PLUS=73
MINUS=74
DIV=75
MOD=76
INC=77
DEC=78
LITERAL_sizeof="sizeof"=79
BNOT=80
LNOT=81
PTR=82
DOT=83
CharLiteral=84
StringLiteral=85
IntOctalConst=86
LongOctalConst=87
UnsignedOctalConst=88
IntIntConst=89
LongIntConst=90
UnsignedIntConst=91
IntHexConst=92
LongHexConst=93
UnsignedHexConst=94
FloatDoubleConst=95
DoubleDoubleConst=96
LongDoubleConst=97
NTypedefName=98
NInitDecl=99
NDeclarator=100
NStructDeclarator=101
NDeclaration=102
NCast=103
NPointerGroup=104
NExpressionGroup=105
NFunctionCallArgs=106
NNonemptyAbstractDeclarator=107
NInitializer=108
NStatementExpr=109
NEmptyExpression=110
NParameterTypeList=111
NFunctionDef=112
NCompoundStatement=113
NParameterDeclaration=114
NCommaExpr=115
NUnaryExpr=116
NLabel=117
NPostfixExpr=118
NRangeExpr=119
NStringSeq=120
NInitializerElementLabel=121
NLcurlyInitializer=122
NAsmAttribute=123
NGnuAsmExpr=124
NTypeMissing=125
Vocabulary=126
Whitespace=127
Comment=128
CPPComment=129
PREPROC_DIRECTIVE("a line directive")=130
Space=131
LineDirective=132
BadStringLiteral=133
Escape=134
Digit=135
LongSuffix=136
UnsignedSuffix=137
FloatSuffix=138
Exponent=139
Number=140
LITERAL___label__="__label__"=141
LITERAL_inline="inline"=142
LITERAL_byte="byte"=143
LITERAL_boolean="boolean"=144
LITERAL_Servo="Servo"=145
LITERAL_Wire="Wire"=146
LITERAL_typeof="typeof"=147
LITERAL___complex="__complex"=148
LITERAL___attribute="__attribute"=149
LITERAL___alignof="__alignof"=150
LITERAL___real="__real"=151
LITERAL___imag="__imag"=152

File diff suppressed because it is too large Load Diff

View File

@@ -1,168 +0,0 @@
// $ANTLR 2.7.2: "expandedWParser.g" -> "WLexer.java"$
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
public interface WLexerTokenTypes {
int EOF = 1;
int NULL_TREE_LOOKAHEAD = 3;
int LITERAL_typedef = 4;
int LITERAL_asm = 5;
int LITERAL_volatile = 6;
int LCURLY = 7;
int RCURLY = 8;
int SEMI = 9;
int LITERAL_struct = 10;
int LITERAL_union = 11;
int LITERAL_enum = 12;
int LITERAL_auto = 13;
int LITERAL_register = 14;
int LITERAL_extern = 15;
int LITERAL_static = 16;
int LITERAL_const = 17;
int LITERAL_void = 18;
int LITERAL_char = 19;
int LITERAL_short = 20;
int LITERAL_int = 21;
int LITERAL_long = 22;
int LITERAL_float = 23;
int LITERAL_double = 24;
int LITERAL_signed = 25;
int LITERAL_unsigned = 26;
int ID = 27;
int COMMA = 28;
int COLON = 29;
int ASSIGN = 30;
int STAR = 31;
int LPAREN = 32;
int RPAREN = 33;
int LBRACKET = 34;
int RBRACKET = 35;
int VARARGS = 36;
int LITERAL_while = 37;
int LITERAL_do = 38;
int LITERAL_for = 39;
int LITERAL_goto = 40;
int LITERAL_continue = 41;
int LITERAL_break = 42;
int LITERAL_return = 43;
int LITERAL_case = 44;
int LITERAL_default = 45;
int LITERAL_if = 46;
int LITERAL_else = 47;
int LITERAL_switch = 48;
int DIV_ASSIGN = 49;
int PLUS_ASSIGN = 50;
int MINUS_ASSIGN = 51;
int STAR_ASSIGN = 52;
int MOD_ASSIGN = 53;
int RSHIFT_ASSIGN = 54;
int LSHIFT_ASSIGN = 55;
int BAND_ASSIGN = 56;
int BOR_ASSIGN = 57;
int BXOR_ASSIGN = 58;
int QUESTION = 59;
int LOR = 60;
int LAND = 61;
int BOR = 62;
int BXOR = 63;
int BAND = 64;
int EQUAL = 65;
int NOT_EQUAL = 66;
int LT = 67;
int LTE = 68;
int GT = 69;
int GTE = 70;
int LSHIFT = 71;
int RSHIFT = 72;
int PLUS = 73;
int MINUS = 74;
int DIV = 75;
int MOD = 76;
int INC = 77;
int DEC = 78;
int LITERAL_sizeof = 79;
int BNOT = 80;
int LNOT = 81;
int PTR = 82;
int DOT = 83;
int CharLiteral = 84;
int StringLiteral = 85;
int IntOctalConst = 86;
int LongOctalConst = 87;
int UnsignedOctalConst = 88;
int IntIntConst = 89;
int LongIntConst = 90;
int UnsignedIntConst = 91;
int IntHexConst = 92;
int LongHexConst = 93;
int UnsignedHexConst = 94;
int FloatDoubleConst = 95;
int DoubleDoubleConst = 96;
int LongDoubleConst = 97;
int NTypedefName = 98;
int NInitDecl = 99;
int NDeclarator = 100;
int NStructDeclarator = 101;
int NDeclaration = 102;
int NCast = 103;
int NPointerGroup = 104;
int NExpressionGroup = 105;
int NFunctionCallArgs = 106;
int NNonemptyAbstractDeclarator = 107;
int NInitializer = 108;
int NStatementExpr = 109;
int NEmptyExpression = 110;
int NParameterTypeList = 111;
int NFunctionDef = 112;
int NCompoundStatement = 113;
int NParameterDeclaration = 114;
int NCommaExpr = 115;
int NUnaryExpr = 116;
int NLabel = 117;
int NPostfixExpr = 118;
int NRangeExpr = 119;
int NStringSeq = 120;
int NInitializerElementLabel = 121;
int NLcurlyInitializer = 122;
int NAsmAttribute = 123;
int NGnuAsmExpr = 124;
int NTypeMissing = 125;
int Vocabulary = 126;
int Whitespace = 127;
int Comment = 128;
int CPPComment = 129;
int PREPROC_DIRECTIVE = 130;
int Space = 131;
int LineDirective = 132;
int BadStringLiteral = 133;
int Escape = 134;
int Digit = 135;
int LongSuffix = 136;
int UnsignedSuffix = 137;
int FloatSuffix = 138;
int Exponent = 139;
int Number = 140;
int LITERAL___label__ = 141;
int LITERAL_inline = 142;
int LITERAL_byte = 143;
int LITERAL_boolean = 144;
int LITERAL_Servo = 145;
int LITERAL_Wire = 146;
int LITERAL_typeof = 147;
int LITERAL___complex = 148;
int LITERAL___attribute = 149;
int LITERAL___alignof = 150;
int LITERAL___real = 151;
int LITERAL___imag = 152;
int LITERAL___extension__ = 153;
int IntSuffix = 154;
int NumberSuffix = 155;
int IDMEAT = 156;
int WideCharLiteral = 157;
int WideStringLiteral = 158;
}

View File

@@ -1,157 +0,0 @@
// $ANTLR 2.7.2: expandedWParser.g -> WLexerTokenTypes.txt$
WLexer // output token vocab name
LITERAL_typedef="typedef"=4
LITERAL_asm="asm"=5
LITERAL_volatile="volatile"=6
LCURLY=7
RCURLY=8
SEMI=9
LITERAL_struct="struct"=10
LITERAL_union="union"=11
LITERAL_enum="enum"=12
LITERAL_auto="auto"=13
LITERAL_register="register"=14
LITERAL_extern="extern"=15
LITERAL_static="static"=16
LITERAL_const="const"=17
LITERAL_void="void"=18
LITERAL_char="char"=19
LITERAL_short="short"=20
LITERAL_int="int"=21
LITERAL_long="long"=22
LITERAL_float="float"=23
LITERAL_double="double"=24
LITERAL_signed="signed"=25
LITERAL_unsigned="unsigned"=26
ID=27
COMMA=28
COLON=29
ASSIGN=30
STAR=31
LPAREN=32
RPAREN=33
LBRACKET=34
RBRACKET=35
VARARGS=36
LITERAL_while="while"=37
LITERAL_do="do"=38
LITERAL_for="for"=39
LITERAL_goto="goto"=40
LITERAL_continue="continue"=41
LITERAL_break="break"=42
LITERAL_return="return"=43
LITERAL_case="case"=44
LITERAL_default="default"=45
LITERAL_if="if"=46
LITERAL_else="else"=47
LITERAL_switch="switch"=48
DIV_ASSIGN=49
PLUS_ASSIGN=50
MINUS_ASSIGN=51
STAR_ASSIGN=52
MOD_ASSIGN=53
RSHIFT_ASSIGN=54
LSHIFT_ASSIGN=55
BAND_ASSIGN=56
BOR_ASSIGN=57
BXOR_ASSIGN=58
QUESTION=59
LOR=60
LAND=61
BOR=62
BXOR=63
BAND=64
EQUAL=65
NOT_EQUAL=66
LT=67
LTE=68
GT=69
GTE=70
LSHIFT=71
RSHIFT=72
PLUS=73
MINUS=74
DIV=75
MOD=76
INC=77
DEC=78
LITERAL_sizeof="sizeof"=79
BNOT=80
LNOT=81
PTR=82
DOT=83
CharLiteral=84
StringLiteral=85
IntOctalConst=86
LongOctalConst=87
UnsignedOctalConst=88
IntIntConst=89
LongIntConst=90
UnsignedIntConst=91
IntHexConst=92
LongHexConst=93
UnsignedHexConst=94
FloatDoubleConst=95
DoubleDoubleConst=96
LongDoubleConst=97
NTypedefName=98
NInitDecl=99
NDeclarator=100
NStructDeclarator=101
NDeclaration=102
NCast=103
NPointerGroup=104
NExpressionGroup=105
NFunctionCallArgs=106
NNonemptyAbstractDeclarator=107
NInitializer=108
NStatementExpr=109
NEmptyExpression=110
NParameterTypeList=111
NFunctionDef=112
NCompoundStatement=113
NParameterDeclaration=114
NCommaExpr=115
NUnaryExpr=116
NLabel=117
NPostfixExpr=118
NRangeExpr=119
NStringSeq=120
NInitializerElementLabel=121
NLcurlyInitializer=122
NAsmAttribute=123
NGnuAsmExpr=124
NTypeMissing=125
Vocabulary=126
Whitespace=127
Comment=128
CPPComment=129
PREPROC_DIRECTIVE("a line directive")=130
Space=131
LineDirective=132
BadStringLiteral=133
Escape=134
Digit=135
LongSuffix=136
UnsignedSuffix=137
FloatSuffix=138
Exponent=139
Number=140
LITERAL___label__="__label__"=141
LITERAL_inline="inline"=142
LITERAL_byte="byte"=143
LITERAL_boolean="boolean"=144
LITERAL_Servo="Servo"=145
LITERAL_Wire="Wire"=146
LITERAL_typeof="typeof"=147
LITERAL___complex="__complex"=148
LITERAL___attribute="__attribute"=149
LITERAL___alignof="__alignof"=150
LITERAL___real="__real"=151
LITERAL___imag="__imag"=152
LITERAL___extension__="__extension__"=153
IntSuffix=154
NumberSuffix=155
IDMEAT=156
WideCharLiteral=157
WideStringLiteral=158

View File

@@ -1,856 +0,0 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Non, Inc. 1998 -- All Rights Reserved
PROJECT: C Compiler
MODULE: WParser
FILE: WParser.g
AUTHOR: Monty Zukowski (jamz@cdsnet.net) April 28, 1998
MODIFICATIONS: Hernando Barragan added support for the Wiring language
DESCRIPTION:
This is a grammar for the GNU C compiler. It is a
grammar subclass of StdCParser, overriding only those
rules which are different from Standard C.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
header {
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
}
class WParser extends StdCParser;
options
{
k = 2;
exportVocab = W;
buildAST = true;
ASTLabelType = "TNode";
defaultErrorHandler = false;
// Copied following options from java grammar.
codeGenMakeSwitchThreshold = 2;
codeGenBitsetTestThreshold = 3;
}
{
// Suppport C++-style single-line comments?
public static boolean CPPComments = true;
// access to symbol table
public CSymbolTable symbolTable = new CSymbolTable();
// source for names to unnamed scopes
protected int unnamedScopeCounter = 0;
public boolean isTypedefName(String name) {
boolean returnValue = false;
TNode node = symbolTable.lookupNameInCurrentScope(name);
for (; node != null; node = (TNode) node.getNextSibling() ) {
if(node.getType() == LITERAL_typedef) {
returnValue = true;
break;
}
}
return returnValue;
}
public String getAScopeName() {
return "" + (unnamedScopeCounter++);
}
public void pushScope(String scopeName) {
symbolTable.pushScope(scopeName);
}
public void popScope() {
symbolTable.popScope();
}
int traceDepth = 0;
public void reportError(RecognitionException ex) {
try {
System.err.println("ANTLR Parsing Error: "+ex + " token name:" + tokenNames[LA(1)]);
ex.printStackTrace(System.err);
}
catch (TokenStreamException e) {
System.err.println("ANTLR Parsing Error: "+ex);
ex.printStackTrace(System.err);
}
}
public void reportError(String s) {
System.err.println("ANTLR Parsing Error from String: " + s);
}
public void reportWarning(String s) {
System.err.println("ANTLR Parsing Warning from String: " + s);
}
public void match(int t) throws MismatchedTokenException {
boolean debugging = false;
if ( debugging ) {
for (int x=0; x<traceDepth; x++) System.out.print(" ");
try {
System.out.println("Match("+tokenNames[t]+") with LA(1)="+
tokenNames[LA(1)] + ((inputState.guessing>0)?" [inputState.guessing "+ inputState.guessing + "]":""));
}
catch (TokenStreamException e) {
System.out.println("Match("+tokenNames[t]+") " + ((inputState.guessing>0)?" [inputState.guessing "+ inputState.guessing + "]":""));
}
}
try {
if ( LA(1)!=t ) {
if ( debugging ){
for (int x=0; x<traceDepth; x++) System.out.print(" ");
System.out.println("token mismatch: "+tokenNames[LA(1)]
+ "!="+tokenNames[t]);
}
throw new MismatchedTokenException(tokenNames, LT(1), t, false, getFilename());
} else {
// mark token as consumed -- fetch next token deferred until LA/LT
consume();
}
}
catch (TokenStreamException e) {
}
}
public void traceIn(String rname) {
traceDepth += 1;
for (int x=0; x<traceDepth; x++) System.out.print(" ");
try {
System.out.println("> "+rname+"; LA(1)==("+ tokenNames[LT(1).getType()]
+ ") " + LT(1).getText() + " [inputState.guessing "+ inputState.guessing + "]");
}
catch (TokenStreamException e) {
}
}
public void traceOut(String rname) {
for (int x=0; x<traceDepth; x++) System.out.print(" ");
try {
System.out.println("< "+rname+"; LA(1)==("+ tokenNames[LT(1).getType()]
+ ") "+LT(1).getText() + " [inputState.guessing "+ inputState.guessing + "]");
}
catch (TokenStreamException e) {
}
traceDepth -= 1;
}
}
translationUnit
: ( externalList )? /* Empty source files are allowed. */
;
asm_expr
: "asm"^
("volatile")? LCURLY expr RCURLY ( SEMI )+
;
idList
: ID ( options{warnWhenFollowAmbig=false;}: COMMA ID )*
;
externalDef
: ( "typedef" | declaration )=> declaration
| ( functionPrefix )=> functionDef
| typelessDeclaration
| asm_expr
| SEMI
;
/* these two are here because GCC allows "cat = 13;" as a valid program! */
functionPrefix
{ String declName; }
: ( (functionDeclSpecifiers)=> ds:functionDeclSpecifiers
| //epsilon
)
declName = d:declarator[true]
( declaration )* (VARARGS)? ( SEMI )*
LCURLY
;
typelessDeclaration
{ AST typeMissing = #[NTypeMissing]; }
: initDeclList[typeMissing] SEMI { ## = #( #[NTypeMissing], ##); }
;
initializer
: ( ( ( (initializerElementLabel)=> initializerElementLabel )?
( assignExpr | lcurlyInitializer ) { ## = #( #[NInitializer], ## ); }
)
| lcurlyInitializer
)
;
// GCC allows more specific initializers
initializerElementLabel
: ( ( LBRACKET ((constExpr VARARGS)=> rangeExpr | constExpr) RBRACKET (ASSIGN)? )
| ID COLON
| DOT ID ASSIGN
)
{ ## = #( #[NInitializerElementLabel], ##) ; }
;
// GCC allows empty initializer lists
lcurlyInitializer
:
LCURLY^ (initializerList ( COMMA! )? )? RCURLY
{ ##.setType( NLcurlyInitializer ); }
;
initializerList
: initializer ( options{warnWhenFollowAmbig=false;}:COMMA! initializer )*
;
declarator[boolean isFunctionDefinition] returns [String declName]
{ declName = ""; }
:
( pointerGroup )?
( id:ID { declName = id.getText(); }
| LPAREN declName = declarator[false] RPAREN
)
( declaratorParamaterList[isFunctionDefinition, declName]
| LBRACKET ( expr )? RBRACKET
)*
{ ## = #( #[NDeclarator], ## ); }
;
declaratorParamaterList[boolean isFunctionDefinition, String declName]
:
LPAREN^
{
if (isFunctionDefinition) {
pushScope(declName);
}
else {
pushScope("!"+declName);
}
}
(
(declSpecifiers)=> parameterTypeList
| (idList)?
)
{
popScope();
}
( COMMA! )?
RPAREN
{ ##.setType(NParameterTypeList); }
;
parameterTypeList
: parameterDeclaration
( options {
warnWhenFollowAmbig = false;
} :
( COMMA | SEMI )
parameterDeclaration
)*
( ( COMMA | SEMI )
VARARGS
)?
;
declarationList
: ( options { // this loop properly aborts when
// it finds a non-typedefName ID MBZ
warnWhenFollowAmbig = false;
} :
localLabelDeclaration
| ( declarationPredictor )=> declaration
)+
;
localLabelDeclaration
: ( //GNU note: any __label__ declarations must come before regular declarations.
"__label__"^ ID (options{warnWhenFollowAmbig=false;}: COMMA! ID)* ( COMMA! )? ( SEMI! )+
)
;
declaration
{ AST ds1 = null; }
: ds:declSpecifiers { ds1 = astFactory.dupList(#ds); }
(
initDeclList[ds1]
)?
( SEMI )+
{ ## = #( #[NDeclaration], ##); }
;
functionStorageClassSpecifier
: "extern"
| "static"
| "inline"
;
typeSpecifier [int specCount] returns [int retSpecCount]
{ retSpecCount = specCount + 1; }
:
( "void"
| "char"
| "short"
| "int"
| "long"
| "float"
| "double"
| "signed"
| "unsigned"
| "byte"
| "boolean"
| "Servo"
| "Wire"
| structOrUnionSpecifier ( options{warnWhenFollowAmbig=false;}: attributeDecl )*
| enumSpecifier
| { specCount==0 }? typedefName
| "typeof"^ LPAREN
( ( typeName )=> typeName
| expr
)
RPAREN
| "__complex"
)
;
structOrUnionSpecifier
{ String scopeName; }
: sou:structOrUnion!
( ( ID LCURLY )=> i:ID l:LCURLY
{
scopeName = #sou.getText() + " " + #i.getText();
#l.setText(scopeName);
pushScope(scopeName);
}
( structDeclarationList )?
{ popScope();}
RCURLY
| l1:LCURLY
{
scopeName = getAScopeName();
#l1.setText(scopeName);
pushScope(scopeName);
}
( structDeclarationList )?
{ popScope(); }
RCURLY
| ID
)
{
## = #( #sou, ## );
}
;
structDeclaration
: specifierQualifierList structDeclaratorList ( COMMA! )? ( SEMI! )+
;
structDeclaratorList
: structDeclarator ( options{warnWhenFollowAmbig=false;}: COMMA! structDeclarator )*
;
structDeclarator
: ( declarator[false] )?
( COLON constExpr )?
( attributeDecl )*
{ ## = #( #[NStructDeclarator], ##); }
;
enumSpecifier
: "enum"^
( ( ID LCURLY )=> i:ID LCURLY enumList[i.getText()] RCURLY
| LCURLY enumList["anonymous"] RCURLY
| ID
)
;
enumList[String enumName]
: enumerator[enumName] ( options{warnWhenFollowAmbig=false;}: COMMA! enumerator[enumName] )* ( COMMA! )?
;
initDeclList[AST declarationSpecifiers]
: initDecl[declarationSpecifiers]
( options{warnWhenFollowAmbig=false;}: COMMA! initDecl[declarationSpecifiers] )*
( COMMA! )?
;
initDecl[AST declarationSpecifiers]
{ String declName = ""; }
: declName = d:declarator[false]
{ AST ds1, d1;
ds1 = astFactory.dupList(declarationSpecifiers);
d1 = astFactory.dupList(#d);
symbolTable.add(declName, #(null, ds1, d1) );
}
( attributeDecl )*
( ASSIGN initializer
| COLON expr
)?
{ ## = #( #[NInitDecl], ## ); }
;
attributeDecl
: "__attribute"^ LPAREN LPAREN attributeList RPAREN RPAREN
| "asm"^ LPAREN stringConst RPAREN { ##.setType( NAsmAttribute ); }
;
attributeList
: attribute ( options{warnWhenFollowAmbig=false;}: COMMA attribute)* ( COMMA )?
;
attribute
: ( ~(LPAREN | RPAREN | COMMA)
| LPAREN attributeList RPAREN
)*
;
compoundStatement[String scopeName]
: LCURLY^
{
pushScope(scopeName);
}
( //this ambiguity is ok, declarationList and nestedFunctionDef end properly
options {
warnWhenFollowAmbig = false;
} :
( "typedef" | "__label__" | declaration )=> declarationList
| (nestedFunctionDef)=> nestedFunctionDef
)*
( statementList )?
{ popScope(); }
RCURLY
{ ##.setType( NCompoundStatement ); ##.setAttribute( "scopeName", scopeName ); }
;
nestedFunctionDef
{ String declName; }
: ( "auto" )? //only for nested functions
( (functionDeclSpecifiers)=> ds:functionDeclSpecifiers
)?
declName = d:declarator[false]
{
AST d2, ds2;
d2 = astFactory.dupList(#d);
ds2 = astFactory.dupList(#ds);
symbolTable.add(declName, #(null, ds2, d2));
pushScope(declName);
}
( declaration )*
{ popScope(); }
compoundStatement[declName]
{ ## = #( #[NFunctionDef], ## );}
;
statement
: SEMI // Empty statements
| compoundStatement[getAScopeName()] // Group of statements
| expr SEMI! { ## = #( #[NStatementExpr], ## );} // Expressions
// Iteration statements:
| "while"^ LPAREN! expr RPAREN! statement
| "do"^ statement "while"! LPAREN! expr RPAREN! SEMI!
|! "for"
LPAREN ( e1:expr )? SEMI ( e2:expr )? SEMI ( e3:expr )? RPAREN
s:statement
{
if ( #e1 == null) { #e1 = #[ NEmptyExpression ]; }
if ( #e2 == null) { #e2 = #[ NEmptyExpression ]; }
if ( #e3 == null) { #e3 = #[ NEmptyExpression ]; }
## = #( #[LITERAL_for, "for"], #e1, #e2, #e3, #s );
}
// Jump statements:
| "goto"^ expr SEMI!
| "continue" SEMI!
| "break" SEMI!
| "return"^ ( expr )? SEMI!
| ID COLON! (options {warnWhenFollowAmbig=false;}: statement)? { ## = #( #[NLabel], ## ); }
// GNU allows range expressions in case statements
| "case"^ ((constExpr VARARGS)=> rangeExpr | constExpr) COLON! ( options{warnWhenFollowAmbig=false;}:statement )?
| "default"^ COLON! ( options{warnWhenFollowAmbig=false;}: statement )?
// Selection statements:
| "if"^
LPAREN! expr RPAREN! statement
( //standard if-else ambiguity
options {
warnWhenFollowAmbig = false;
} :
"else" statement )?
| "switch"^ LPAREN! expr RPAREN! statement
;
conditionalExpr
: logicalOrExpr
( QUESTION^ (expr)? COLON conditionalExpr )?
;
rangeExpr //used in initializers only
: constExpr VARARGS constExpr
{ ## = #(#[NRangeExpr], ##); }
;
castExpr
: ( LPAREN typeName RPAREN )=>
LPAREN^ typeName RPAREN ( castExpr | lcurlyInitializer )
{ ##.setType(NCast); }
| unaryExpr
;
nonemptyAbstractDeclarator
: (
pointerGroup
( (LPAREN
( nonemptyAbstractDeclarator
| parameterTypeList
)?
( COMMA! )?
RPAREN)
| (LBRACKET (expr)? RBRACKET)
)*
| ( (LPAREN
( nonemptyAbstractDeclarator
| parameterTypeList
)?
( COMMA! )?
RPAREN)
| (LBRACKET (expr)? RBRACKET)
)+
)
{ ## = #( #[NNonemptyAbstractDeclarator], ## ); }
;
unaryExpr
: postfixExpr
| INC^ castExpr
| DEC^ castExpr
| u:unaryOperator castExpr { ## = #( #[NUnaryExpr], ## ); }
| "sizeof"^
( ( LPAREN typeName )=> LPAREN typeName RPAREN
| unaryExpr
)
| "__alignof"^
( ( LPAREN typeName )=> LPAREN typeName RPAREN
| unaryExpr
)
| gnuAsmExpr
;
unaryOperator
: BAND
| STAR
| PLUS
| MINUS
| BNOT //also stands for complex conjugation
| LNOT
| LAND //for label dereference (&&label)
| "__real"
| "__imag"
;
gnuAsmExpr
: "asm"^ ("volatile")?
LPAREN stringConst
( options { warnWhenFollowAmbig = false; }:
COLON (strOptExprPair ( COMMA strOptExprPair)* )?
( options { warnWhenFollowAmbig = false; }:
COLON (strOptExprPair ( COMMA strOptExprPair)* )?
)?
)?
( COLON stringConst ( COMMA stringConst)* )?
RPAREN
{ ##.setType(NGnuAsmExpr); }
;
//GCC requires the PARENs
strOptExprPair
: stringConst ( LPAREN expr RPAREN )?
;
primaryExpr
: ID
| Number
| charConst
| stringConst
// JTC:
// ID should catch the enumerator
// leaving it in gives ambiguous err
// | enumerator
| (LPAREN LCURLY) => LPAREN^ compoundStatement[getAScopeName()] RPAREN
| LPAREN^ expr RPAREN { ##.setType(NExpressionGroup); }
;
{
// import CToken;
import java.io.*;
// import LineObject;
import antlr.*;
}
class WLexer extends StdCLexer;
options
{
k = 3;
importVocab = W;
testLiterals = false;
}
tokens {
LITERAL___extension__ = "__extension__";
}
{
public void initialize(String src)
{
setOriginalSource(src);
initialize();
}
public void initialize()
{
literals.put(new ANTLRHashString("__alignof__", this), new Integer(LITERAL___alignof));
literals.put(new ANTLRHashString("__asm", this), new Integer(LITERAL_asm));
literals.put(new ANTLRHashString("__asm__", this), new Integer(LITERAL_asm));
literals.put(new ANTLRHashString("__attribute__", this), new Integer(LITERAL___attribute));
literals.put(new ANTLRHashString("__complex__", this), new Integer(LITERAL___complex));
literals.put(new ANTLRHashString("__const", this), new Integer(LITERAL_const));
literals.put(new ANTLRHashString("__const__", this), new Integer(LITERAL_const));
literals.put(new ANTLRHashString("__imag__", this), new Integer(LITERAL___imag));
literals.put(new ANTLRHashString("__inline", this), new Integer(LITERAL_inline));
literals.put(new ANTLRHashString("__inline__", this), new Integer(LITERAL_inline));
literals.put(new ANTLRHashString("__real__", this), new Integer(LITERAL___real));
literals.put(new ANTLRHashString("__signed", this), new Integer(LITERAL_signed));
literals.put(new ANTLRHashString("__signed__", this), new Integer(LITERAL_signed));
literals.put(new ANTLRHashString("__typeof", this), new Integer(LITERAL_typeof));
literals.put(new ANTLRHashString("__typeof__", this), new Integer(LITERAL_typeof));
literals.put(new ANTLRHashString("__volatile", this), new Integer(LITERAL_volatile));
literals.put(new ANTLRHashString("__volatile__", this), new Integer(LITERAL_volatile));
}
LineObject lineObject = new LineObject();
String originalSource = "";
PreprocessorInfoChannel preprocessorInfoChannel = new PreprocessorInfoChannel();
int tokenNumber = 0;
boolean countingTokens = true;
int deferredLineCount = 0;
public void setCountingTokens(boolean ct)
{
countingTokens = ct;
if ( countingTokens ) {
tokenNumber = 0;
}
else {
tokenNumber = 1;
}
}
public void setOriginalSource(String src)
{
originalSource = src;
lineObject.setSource(src);
}
public void setSource(String src)
{
lineObject.setSource(src);
}
public PreprocessorInfoChannel getPreprocessorInfoChannel()
{
return preprocessorInfoChannel;
}
public void setPreprocessingDirective(String pre)
{
preprocessorInfoChannel.addLineForTokenNumber( pre, new Integer(tokenNumber) );
}
protected Token makeToken(int t)
{
if ( t != Token.SKIP && countingTokens) {
tokenNumber++;
}
CToken tok = (CToken) super.makeToken(t);
tok.setLine(lineObject.line);
tok.setSource(lineObject.source);
tok.setTokenNumber(tokenNumber);
lineObject.line += deferredLineCount;
deferredLineCount = 0;
return tok;
}
public void deferredNewline() {
deferredLineCount++;
}
public void newline() {
lineObject.newline();
}
}
Whitespace
: ( ( ' ' | '\t' | '\014')
| "\r\n" { newline(); }
| ( '\n' | '\r' ) { newline(); }
) { _ttype = Token.SKIP; }
;
protected
Escape
: '\\'
( options{warnWhenFollowAmbig=false;}:
~('0'..'7' | 'x')
| ('0'..'3') ( options{warnWhenFollowAmbig=false;}: Digit )*
| ('4'..'7') ( options{warnWhenFollowAmbig=false;}: Digit )*
| 'x' ( options{warnWhenFollowAmbig=false;}: Digit | 'a'..'f' | 'A'..'F' )+
)
;
protected IntSuffix
: 'L'
| 'l'
| 'U'
| 'u'
| 'I'
| 'i'
| 'J'
| 'j'
;
protected NumberSuffix
:
IntSuffix
| 'F'
| 'f'
;
Number
: ( ( Digit )+ ( '.' | 'e' | 'E' ) )=> ( Digit )+
( '.' ( Digit )* ( Exponent )?
| Exponent
)
( NumberSuffix
)*
| ( "..." )=> "..." { _ttype = VARARGS; }
| '.' { _ttype = DOT; }
( ( Digit )+ ( Exponent )?
{ _ttype = Number; }
( NumberSuffix
)*
)?
| '0' ( '0'..'7' )*
( NumberSuffix
)*
| '1'..'9' ( Digit )*
( NumberSuffix
)*
| '0' ( 'x' | 'X' ) ( 'a'..'f' | 'A'..'F' | Digit )+
( IntSuffix
)*
;
IDMEAT
:
i:ID {
if ( i.getType() == LITERAL___extension__ ) {
$setType(Token.SKIP);
}
else {
$setType(i.getType());
}
}
;
protected ID
options
{
testLiterals = true;
}
: ( 'a'..'z' | 'A'..'Z' | '_' | '$')
( 'a'..'z' | 'A'..'Z' | '_' | '$' | '0'..'9' )*
;
WideCharLiteral
:
'L' CharLiteral
{ $setType(CharLiteral); }
;
WideStringLiteral
:
'L' StringLiteral
{ $setType(StringLiteral); }
;
StringLiteral
:
'"'
( ('\\' ~('\n'))=> Escape
| ( '\r' { newline(); }
| '\n' {
newline();
}
| '\\' '\n' {
newline();
}
)
| ~( '"' | '\r' | '\n' | '\\' )
)*
'"'
;

File diff suppressed because it is too large Load Diff

View File

@@ -1,162 +0,0 @@
// $ANTLR 2.7.2: "expandedWParser.g" -> "WLexer.java"$
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
public interface WTokenTypes {
int EOF = 1;
int NULL_TREE_LOOKAHEAD = 3;
int LITERAL_typedef = 4;
int LITERAL_asm = 5;
int LITERAL_volatile = 6;
int LCURLY = 7;
int RCURLY = 8;
int SEMI = 9;
int LITERAL_struct = 10;
int LITERAL_union = 11;
int LITERAL_enum = 12;
int LITERAL_auto = 13;
int LITERAL_register = 14;
int LITERAL_extern = 15;
int LITERAL_static = 16;
int LITERAL_const = 17;
int LITERAL_void = 18;
int LITERAL_char = 19;
int LITERAL_short = 20;
int LITERAL_int = 21;
int LITERAL_long = 22;
int LITERAL_float = 23;
int LITERAL_double = 24;
int LITERAL_signed = 25;
int LITERAL_unsigned = 26;
int ID = 27;
int COMMA = 28;
int COLON = 29;
int ASSIGN = 30;
int STAR = 31;
int LPAREN = 32;
int RPAREN = 33;
int LBRACKET = 34;
int RBRACKET = 35;
int VARARGS = 36;
int LITERAL_while = 37;
int LITERAL_do = 38;
int LITERAL_for = 39;
int LITERAL_goto = 40;
int LITERAL_continue = 41;
int LITERAL_break = 42;
int LITERAL_return = 43;
int LITERAL_case = 44;
int LITERAL_default = 45;
int LITERAL_if = 46;
int LITERAL_else = 47;
int LITERAL_switch = 48;
int DIV_ASSIGN = 49;
int PLUS_ASSIGN = 50;
int MINUS_ASSIGN = 51;
int STAR_ASSIGN = 52;
int MOD_ASSIGN = 53;
int RSHIFT_ASSIGN = 54;
int LSHIFT_ASSIGN = 55;
int BAND_ASSIGN = 56;
int BOR_ASSIGN = 57;
int BXOR_ASSIGN = 58;
int QUESTION = 59;
int LOR = 60;
int LAND = 61;
int BOR = 62;
int BXOR = 63;
int BAND = 64;
int EQUAL = 65;
int NOT_EQUAL = 66;
int LT = 67;
int LTE = 68;
int GT = 69;
int GTE = 70;
int LSHIFT = 71;
int RSHIFT = 72;
int PLUS = 73;
int MINUS = 74;
int DIV = 75;
int MOD = 76;
int INC = 77;
int DEC = 78;
int LITERAL_sizeof = 79;
int BNOT = 80;
int LNOT = 81;
int PTR = 82;
int DOT = 83;
int CharLiteral = 84;
int StringLiteral = 85;
int IntOctalConst = 86;
int LongOctalConst = 87;
int UnsignedOctalConst = 88;
int IntIntConst = 89;
int LongIntConst = 90;
int UnsignedIntConst = 91;
int IntHexConst = 92;
int LongHexConst = 93;
int UnsignedHexConst = 94;
int FloatDoubleConst = 95;
int DoubleDoubleConst = 96;
int LongDoubleConst = 97;
int NTypedefName = 98;
int NInitDecl = 99;
int NDeclarator = 100;
int NStructDeclarator = 101;
int NDeclaration = 102;
int NCast = 103;
int NPointerGroup = 104;
int NExpressionGroup = 105;
int NFunctionCallArgs = 106;
int NNonemptyAbstractDeclarator = 107;
int NInitializer = 108;
int NStatementExpr = 109;
int NEmptyExpression = 110;
int NParameterTypeList = 111;
int NFunctionDef = 112;
int NCompoundStatement = 113;
int NParameterDeclaration = 114;
int NCommaExpr = 115;
int NUnaryExpr = 116;
int NLabel = 117;
int NPostfixExpr = 118;
int NRangeExpr = 119;
int NStringSeq = 120;
int NInitializerElementLabel = 121;
int NLcurlyInitializer = 122;
int NAsmAttribute = 123;
int NGnuAsmExpr = 124;
int NTypeMissing = 125;
int Vocabulary = 126;
int Whitespace = 127;
int Comment = 128;
int CPPComment = 129;
int PREPROC_DIRECTIVE = 130;
int Space = 131;
int LineDirective = 132;
int BadStringLiteral = 133;
int Escape = 134;
int Digit = 135;
int LongSuffix = 136;
int UnsignedSuffix = 137;
int FloatSuffix = 138;
int Exponent = 139;
int Number = 140;
int LITERAL___label__ = 141;
int LITERAL_inline = 142;
int LITERAL_byte = 143;
int LITERAL_boolean = 144;
int LITERAL_Servo = 145;
int LITERAL_Wire = 146;
int LITERAL_typeof = 147;
int LITERAL___complex = 148;
int LITERAL___attribute = 149;
int LITERAL___alignof = 150;
int LITERAL___real = 151;
int LITERAL___imag = 152;
}

View File

@@ -1,151 +0,0 @@
// $ANTLR 2.7.2: expandedWParser.g -> WTokenTypes.txt$
W // output token vocab name
LITERAL_typedef="typedef"=4
LITERAL_asm="asm"=5
LITERAL_volatile="volatile"=6
LCURLY=7
RCURLY=8
SEMI=9
LITERAL_struct="struct"=10
LITERAL_union="union"=11
LITERAL_enum="enum"=12
LITERAL_auto="auto"=13
LITERAL_register="register"=14
LITERAL_extern="extern"=15
LITERAL_static="static"=16
LITERAL_const="const"=17
LITERAL_void="void"=18
LITERAL_char="char"=19
LITERAL_short="short"=20
LITERAL_int="int"=21
LITERAL_long="long"=22
LITERAL_float="float"=23
LITERAL_double="double"=24
LITERAL_signed="signed"=25
LITERAL_unsigned="unsigned"=26
ID=27
COMMA=28
COLON=29
ASSIGN=30
STAR=31
LPAREN=32
RPAREN=33
LBRACKET=34
RBRACKET=35
VARARGS=36
LITERAL_while="while"=37
LITERAL_do="do"=38
LITERAL_for="for"=39
LITERAL_goto="goto"=40
LITERAL_continue="continue"=41
LITERAL_break="break"=42
LITERAL_return="return"=43
LITERAL_case="case"=44
LITERAL_default="default"=45
LITERAL_if="if"=46
LITERAL_else="else"=47
LITERAL_switch="switch"=48
DIV_ASSIGN=49
PLUS_ASSIGN=50
MINUS_ASSIGN=51
STAR_ASSIGN=52
MOD_ASSIGN=53
RSHIFT_ASSIGN=54
LSHIFT_ASSIGN=55
BAND_ASSIGN=56
BOR_ASSIGN=57
BXOR_ASSIGN=58
QUESTION=59
LOR=60
LAND=61
BOR=62
BXOR=63
BAND=64
EQUAL=65
NOT_EQUAL=66
LT=67
LTE=68
GT=69
GTE=70
LSHIFT=71
RSHIFT=72
PLUS=73
MINUS=74
DIV=75
MOD=76
INC=77
DEC=78
LITERAL_sizeof="sizeof"=79
BNOT=80
LNOT=81
PTR=82
DOT=83
CharLiteral=84
StringLiteral=85
IntOctalConst=86
LongOctalConst=87
UnsignedOctalConst=88
IntIntConst=89
LongIntConst=90
UnsignedIntConst=91
IntHexConst=92
LongHexConst=93
UnsignedHexConst=94
FloatDoubleConst=95
DoubleDoubleConst=96
LongDoubleConst=97
NTypedefName=98
NInitDecl=99
NDeclarator=100
NStructDeclarator=101
NDeclaration=102
NCast=103
NPointerGroup=104
NExpressionGroup=105
NFunctionCallArgs=106
NNonemptyAbstractDeclarator=107
NInitializer=108
NStatementExpr=109
NEmptyExpression=110
NParameterTypeList=111
NFunctionDef=112
NCompoundStatement=113
NParameterDeclaration=114
NCommaExpr=115
NUnaryExpr=116
NLabel=117
NPostfixExpr=118
NRangeExpr=119
NStringSeq=120
NInitializerElementLabel=121
NLcurlyInitializer=122
NAsmAttribute=123
NGnuAsmExpr=124
NTypeMissing=125
Vocabulary=126
Whitespace=127
Comment=128
CPPComment=129
PREPROC_DIRECTIVE("a line directive")=130
Space=131
LineDirective=132
BadStringLiteral=133
Escape=134
Digit=135
LongSuffix=136
UnsignedSuffix=137
FloatSuffix=138
Exponent=139
Number=140
LITERAL___label__="__label__"=141
LITERAL_inline="inline"=142
LITERAL_byte="byte"=143
LITERAL_boolean="boolean"=144
LITERAL_Servo="Servo"=145
LITERAL_Wire="Wire"=146
LITERAL_typeof="typeof"=147
LITERAL___complex="__complex"=148
LITERAL___attribute="__attribute"=149
LITERAL___alignof="__alignof"=150
LITERAL___real="__real"=151
LITERAL___imag="__imag"=152

View File

@@ -1,857 +0,0 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Non, Inc. 1998 -- All Rights Reserved
PROJECT: C Compiler
MODULE: WTreeParser
FILE: WTreeParser.g
AUTHOR: Monty Zukowski (jamz@cdsnet.net) April 28, 1998
MODIFICATIONS: Hernando Barragan added support for the Wiring language
DESCRIPTION:
This tree grammar is for a Gnu C AST. No actions in it,
subclass to do something useful.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
header {
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
}
class WTreeParser extends TreeParser;
options
{
importVocab = W;
buildAST = false;
ASTLabelType = "TNode";
// Copied following options from java grammar.
codeGenMakeSwitchThreshold = 2;
codeGenBitsetTestThreshold = 3;
}
{
int traceDepth = 0;
public void reportError(RecognitionException ex) {
if ( ex != null) {
System.err.println("ANTLR Tree Parsing RecognitionException Error: " + ex.getClass().getName() + " " + ex );
ex.printStackTrace(System.err);
}
}
public void reportError(NoViableAltException ex) {
System.err.println("ANTLR Tree Parsing NoViableAltException Error: " + ex.toString());
TNode.printTree( ex.node );
ex.printStackTrace(System.err);
}
public void reportError(MismatchedTokenException ex) {
if ( ex != null) {
TNode.printTree( ex.node );
System.err.println("ANTLR Tree Parsing MismatchedTokenException Error: " + ex );
ex.printStackTrace(System.err);
}
}
public void reportError(String s) {
System.err.println("ANTLR Error from String: " + s);
}
public void reportWarning(String s) {
System.err.println("ANTLR Warning from String: " + s);
}
protected void match(AST t, int ttype) throws MismatchedTokenException {
//System.out.println("match("+ttype+"); cursor is "+t);
super.match(t, ttype);
}
public void match(AST t, BitSet b) throws MismatchedTokenException {
//System.out.println("match("+b+"); cursor is "+t);
super.match(t, b);
}
protected void matchNot(AST t, int ttype) throws MismatchedTokenException {
//System.out.println("matchNot("+ttype+"); cursor is "+t);
super.matchNot(t, ttype);
}
public void traceIn(String rname, AST t) {
traceDepth += 1;
for (int x=0; x<traceDepth; x++) System.out.print(" ");
super.traceIn(rname, t);
}
public void traceOut(String rname, AST t) {
for (int x=0; x<traceDepth; x++) System.out.print(" ");
super.traceOut(rname, t);
traceDepth -= 1;
}
}
translationUnit options {
defaultErrorHandler=false;
}
: ( externalList )?
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
externalList
: ( externalDef )+
;
externalDef
: declaration
| functionDef
| asm_expr
| SEMI
| typelessDeclaration
;
typelessDeclaration
: #(NTypeMissing initDeclList SEMI)
;
asm_expr
: #( "asm" ( "volatile" )? LCURLY expr RCURLY ( SEMI )+ )
;
declaration
: #( NDeclaration
declSpecifiers
(
initDeclList
)?
( SEMI )+
)
;
declSpecifiers
: ( storageClassSpecifier
| typeQualifier
| typeSpecifier
)+
;
storageClassSpecifier
: "auto"
| "register"
| "typedef"
| functionStorageClassSpecifier
;
functionStorageClassSpecifier
: "extern"
| "static"
| "inline"
;
typeQualifier
: "const"
| "volatile"
;
typeSpecifier
: "void"
| "char"
| "short"
| "int"
| "long"
| "float"
| "double"
| "signed"
| "unsigned"
| "byte"
| "boolean"
| "Servo"
| "Wire"
| structSpecifier ( attributeDecl )*
| unionSpecifier ( attributeDecl )*
| enumSpecifier
| typedefName
| #("typeof" LPAREN
( (typeName )=> typeName
| expr
)
RPAREN
)
| "__complex"
;
typedefName
: #(NTypedefName ID)
;
structSpecifier
: #( "struct" structOrUnionBody )
;
unionSpecifier
: #( "union" structOrUnionBody )
;
structOrUnionBody
: ( (ID LCURLY) => ID LCURLY
( structDeclarationList )?
RCURLY
| LCURLY
( structDeclarationList )?
RCURLY
| ID
)
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
structDeclarationList
: ( structDeclaration )+
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
structDeclaration
: specifierQualifierList structDeclaratorList
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
specifierQualifierList
: (
typeSpecifier
| typeQualifier
)+
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
structDeclaratorList
: ( structDeclarator )+
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
structDeclarator
:
#( NStructDeclarator
( declarator )?
( COLON expr )?
( attributeDecl )*
)
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
enumSpecifier
: #( "enum"
( ID )?
( LCURLY enumList RCURLY )?
)
;
enumList
: ( enumerator )+
;
enumerator
: ID ( ASSIGN expr )?
;
attributeDecl:
#( "__attribute" (.)* )
| #( NAsmAttribute LPAREN expr RPAREN )
;
initDeclList
: ( initDecl )+
;
initDecl
{ String declName = ""; }
: #( NInitDecl
declarator
( attributeDecl )*
( ASSIGN initializer
| COLON expr
)?
)
;
pointerGroup
: #( NPointerGroup ( STAR ( typeQualifier )* )+ )
;
idList
: ID ( COMMA ID )*
;
initializer
: #( NInitializer (initializerElementLabel)? expr )
| lcurlyInitializer
;
initializerElementLabel
: #( NInitializerElementLabel
(
( LBRACKET expr RBRACKET (ASSIGN)? )
| ID COLON
| DOT ID ASSIGN
)
)
;
lcurlyInitializer
: #( NLcurlyInitializer
initializerList
RCURLY
)
;
initializerList
: ( initializer )*
;
declarator
: #( NDeclarator
( pointerGroup )?
( id:ID
| LPAREN declarator RPAREN
)
( #( NParameterTypeList
(
parameterTypeList
| (idList)?
)
RPAREN
)
| LBRACKET ( expr )? RBRACKET
)*
)
;
parameterTypeList
: ( parameterDeclaration ( COMMA | SEMI )? )+ ( VARARGS )?
;
parameterDeclaration
: #( NParameterDeclaration
declSpecifiers
(declarator | nonemptyAbstractDeclarator)?
)
;
functionDef
: #( NFunctionDef
( functionDeclSpecifiers)?
declarator
(declaration | VARARGS)*
compoundStatement
)
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
functionDeclSpecifiers
:
( functionStorageClassSpecifier
| typeQualifier
| typeSpecifier
)+
;
declarationList
:
( //ANTLR doesn't know that declarationList properly eats all the declarations
//so it warns about the ambiguity
options {
warnWhenFollowAmbig = false;
} :
localLabelDecl
| declaration
)+
;
localLabelDecl
: #("__label__" (ID)+ )
;
compoundStatement
: #( NCompoundStatement
( declarationList
| functionDef
)*
( statementList )?
RCURLY
)
;
statementList
: ( statement )+
;
statement
: statementBody
;
statementBody
: SEMI // Empty statements
| compoundStatement // Group of statements
| #(NStatementExpr expr) // Expressions
// Iteration statements:
| #( "while" expr statement )
| #( "do" statement expr )
| #( "for"
expr expr expr
statement
)
// Jump statements:
| #( "goto" expr )
| "continue"
| "break"
| #( "return" ( expr )? )
// Labeled statements:
| #( NLabel ID (statement)? )
| #( "case" expr (statement)? )
| #( "default" (statement)? )
// Selection statements:
| #( "if"
expr statement
( "else" statement )?
)
| #( "switch" expr statement )
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
expr
: assignExpr
| conditionalExpr
| logicalOrExpr
| logicalAndExpr
| inclusiveOrExpr
| exclusiveOrExpr
| bitAndExpr
| equalityExpr
| relationalExpr
| shiftExpr
| additiveExpr
| multExpr
| castExpr
| unaryExpr
| postfixExpr
| primaryExpr
| commaExpr
| emptyExpr
| compoundStatementExpr
| initializer
| rangeExpr
| gnuAsmExpr
;
commaExpr
: #(NCommaExpr expr expr)
;
emptyExpr
: NEmptyExpression
;
compoundStatementExpr
: #(LPAREN compoundStatement RPAREN)
;
rangeExpr
: #(NRangeExpr expr VARARGS expr)
;
gnuAsmExpr
: #(NGnuAsmExpr
("volatile")?
LPAREN stringConst
( options { warnWhenFollowAmbig = false; }:
COLON (strOptExprPair ( COMMA strOptExprPair)* )?
( options { warnWhenFollowAmbig = false; }:
COLON (strOptExprPair ( COMMA strOptExprPair)* )?
)?
)?
( COLON stringConst ( COMMA stringConst)* )?
RPAREN
)
;
strOptExprPair
: stringConst ( LPAREN expr RPAREN )?
;
assignExpr
: #( ASSIGN expr expr)
| #( DIV_ASSIGN expr expr)
| #( PLUS_ASSIGN expr expr)
| #( MINUS_ASSIGN expr expr)
| #( STAR_ASSIGN expr expr)
| #( MOD_ASSIGN expr expr)
| #( RSHIFT_ASSIGN expr expr)
| #( LSHIFT_ASSIGN expr expr)
| #( BAND_ASSIGN expr expr)
| #( BOR_ASSIGN expr expr)
| #( BXOR_ASSIGN expr expr)
;
conditionalExpr
: #( QUESTION expr (expr)? COLON expr )
;
logicalOrExpr
: #( LOR expr expr)
;
logicalAndExpr
: #( LAND expr expr )
;
inclusiveOrExpr
: #( BOR expr expr )
;
exclusiveOrExpr
: #( BXOR expr expr )
;
bitAndExpr
: #( BAND expr expr )
;
equalityExpr
: #( EQUAL expr expr)
| #( NOT_EQUAL expr expr)
;
relationalExpr
: #( LT expr expr)
| #( LTE expr expr)
| #( GT expr expr)
| #( GTE expr expr)
;
shiftExpr
: #( LSHIFT expr expr)
| #( RSHIFT expr expr)
;
additiveExpr
: #( PLUS expr expr)
| #( MINUS expr expr)
;
multExpr
: #( STAR expr expr)
| #( DIV expr expr)
| #( MOD expr expr)
;
castExpr
: #( NCast typeName RPAREN expr)
;
typeName
: specifierQualifierList (nonemptyAbstractDeclarator)?
;
nonemptyAbstractDeclarator
: #( NNonemptyAbstractDeclarator
( pointerGroup
( (LPAREN
( nonemptyAbstractDeclarator
| parameterTypeList
)?
RPAREN)
| (LBRACKET (expr)? RBRACKET)
)*
| ( (LPAREN
( nonemptyAbstractDeclarator
| parameterTypeList
)?
RPAREN)
| (LBRACKET (expr)? RBRACKET)
)+
)
)
;
unaryExpr
: #( INC expr )
| #( DEC expr )
| #( NUnaryExpr unaryOperator expr)
| #( "sizeof"
( ( LPAREN typeName )=> LPAREN typeName RPAREN
| expr
)
)
| #( "__alignof"
( ( LPAREN typeName )=> LPAREN typeName RPAREN
| expr
)
)
;
/*
exception
catch [RecognitionException ex]
{
reportError(ex);
System.out.println("PROBLEM TREE:\n"
+ _t.toStringList());
if (_t!=null) {_t = _t.getNextSibling();}
}
*/
unaryOperator
: BAND
| STAR
| PLUS
| MINUS
| BNOT
| LNOT
| LAND
| "__real"
| "__imag"
;
postfixExpr
: #( NPostfixExpr
primaryExpr
( PTR ID
| DOT ID
| #( NFunctionCallArgs (argExprList)? RPAREN )
| LBRACKET expr RBRACKET
| INC
| DEC
)+
)
;
primaryExpr
: ID
| Number
| charConst
| stringConst
// JTC:
// ID should catch the enumerator
// leaving it in gives ambiguous err
// | enumerator
| #( NExpressionGroup expr )
;
argExprList
: ( expr )+
;
protected
charConst
: CharLiteral
;
protected
stringConst
: #(NStringSeq (StringLiteral)+)
;
protected
intConst
: IntOctalConst
| LongOctalConst
| UnsignedOctalConst
| IntIntConst
| LongIntConst
| UnsignedIntConst
| IntHexConst
| LongHexConst
| UnsignedHexConst
;
protected
floatConst
: FloatDoubleConst
| DoubleDoubleConst
| LongDoubleConst
;

File diff suppressed because it is too large Load Diff

View File

@@ -1,162 +0,0 @@
// $ANTLR 2.7.2: "WTreeParser.g" -> "WTreeParser.java"$
package processing.app.preproc;
import java.io.*;
import antlr.CommonAST;
import antlr.DumpASTVisitor;
public interface WTreeParserTokenTypes {
int EOF = 1;
int NULL_TREE_LOOKAHEAD = 3;
int LITERAL_typedef = 4;
int LITERAL_asm = 5;
int LITERAL_volatile = 6;
int LCURLY = 7;
int RCURLY = 8;
int SEMI = 9;
int LITERAL_struct = 10;
int LITERAL_union = 11;
int LITERAL_enum = 12;
int LITERAL_auto = 13;
int LITERAL_register = 14;
int LITERAL_extern = 15;
int LITERAL_static = 16;
int LITERAL_const = 17;
int LITERAL_void = 18;
int LITERAL_char = 19;
int LITERAL_short = 20;
int LITERAL_int = 21;
int LITERAL_long = 22;
int LITERAL_float = 23;
int LITERAL_double = 24;
int LITERAL_signed = 25;
int LITERAL_unsigned = 26;
int ID = 27;
int COMMA = 28;
int COLON = 29;
int ASSIGN = 30;
int STAR = 31;
int LPAREN = 32;
int RPAREN = 33;
int LBRACKET = 34;
int RBRACKET = 35;
int VARARGS = 36;
int LITERAL_while = 37;
int LITERAL_do = 38;
int LITERAL_for = 39;
int LITERAL_goto = 40;
int LITERAL_continue = 41;
int LITERAL_break = 42;
int LITERAL_return = 43;
int LITERAL_case = 44;
int LITERAL_default = 45;
int LITERAL_if = 46;
int LITERAL_else = 47;
int LITERAL_switch = 48;
int DIV_ASSIGN = 49;
int PLUS_ASSIGN = 50;
int MINUS_ASSIGN = 51;
int STAR_ASSIGN = 52;
int MOD_ASSIGN = 53;
int RSHIFT_ASSIGN = 54;
int LSHIFT_ASSIGN = 55;
int BAND_ASSIGN = 56;
int BOR_ASSIGN = 57;
int BXOR_ASSIGN = 58;
int QUESTION = 59;
int LOR = 60;
int LAND = 61;
int BOR = 62;
int BXOR = 63;
int BAND = 64;
int EQUAL = 65;
int NOT_EQUAL = 66;
int LT = 67;
int LTE = 68;
int GT = 69;
int GTE = 70;
int LSHIFT = 71;
int RSHIFT = 72;
int PLUS = 73;
int MINUS = 74;
int DIV = 75;
int MOD = 76;
int INC = 77;
int DEC = 78;
int LITERAL_sizeof = 79;
int BNOT = 80;
int LNOT = 81;
int PTR = 82;
int DOT = 83;
int CharLiteral = 84;
int StringLiteral = 85;
int IntOctalConst = 86;
int LongOctalConst = 87;
int UnsignedOctalConst = 88;
int IntIntConst = 89;
int LongIntConst = 90;
int UnsignedIntConst = 91;
int IntHexConst = 92;
int LongHexConst = 93;
int UnsignedHexConst = 94;
int FloatDoubleConst = 95;
int DoubleDoubleConst = 96;
int LongDoubleConst = 97;
int NTypedefName = 98;
int NInitDecl = 99;
int NDeclarator = 100;
int NStructDeclarator = 101;
int NDeclaration = 102;
int NCast = 103;
int NPointerGroup = 104;
int NExpressionGroup = 105;
int NFunctionCallArgs = 106;
int NNonemptyAbstractDeclarator = 107;
int NInitializer = 108;
int NStatementExpr = 109;
int NEmptyExpression = 110;
int NParameterTypeList = 111;
int NFunctionDef = 112;
int NCompoundStatement = 113;
int NParameterDeclaration = 114;
int NCommaExpr = 115;
int NUnaryExpr = 116;
int NLabel = 117;
int NPostfixExpr = 118;
int NRangeExpr = 119;
int NStringSeq = 120;
int NInitializerElementLabel = 121;
int NLcurlyInitializer = 122;
int NAsmAttribute = 123;
int NGnuAsmExpr = 124;
int NTypeMissing = 125;
int Vocabulary = 126;
int Whitespace = 127;
int Comment = 128;
int CPPComment = 129;
int PREPROC_DIRECTIVE = 130;
int Space = 131;
int LineDirective = 132;
int BadStringLiteral = 133;
int Escape = 134;
int Digit = 135;
int LongSuffix = 136;
int UnsignedSuffix = 137;
int FloatSuffix = 138;
int Exponent = 139;
int Number = 140;
int LITERAL___label__ = 141;
int LITERAL_inline = 142;
int LITERAL_byte = 143;
int LITERAL_boolean = 144;
int LITERAL_Servo = 145;
int LITERAL_Wire = 146;
int LITERAL_typeof = 147;
int LITERAL___complex = 148;
int LITERAL___attribute = 149;
int LITERAL___alignof = 150;
int LITERAL___real = 151;
int LITERAL___imag = 152;
}

View File

@@ -1,151 +0,0 @@
// $ANTLR 2.7.2: WTreeParser.g -> WTreeParserTokenTypes.txt$
WTreeParser // output token vocab name
LITERAL_typedef="typedef"=4
LITERAL_asm="asm"=5
LITERAL_volatile="volatile"=6
LCURLY=7
RCURLY=8
SEMI=9
LITERAL_struct="struct"=10
LITERAL_union="union"=11
LITERAL_enum="enum"=12
LITERAL_auto="auto"=13
LITERAL_register="register"=14
LITERAL_extern="extern"=15
LITERAL_static="static"=16
LITERAL_const="const"=17
LITERAL_void="void"=18
LITERAL_char="char"=19
LITERAL_short="short"=20
LITERAL_int="int"=21
LITERAL_long="long"=22
LITERAL_float="float"=23
LITERAL_double="double"=24
LITERAL_signed="signed"=25
LITERAL_unsigned="unsigned"=26
ID=27
COMMA=28
COLON=29
ASSIGN=30
STAR=31
LPAREN=32
RPAREN=33
LBRACKET=34
RBRACKET=35
VARARGS=36
LITERAL_while="while"=37
LITERAL_do="do"=38
LITERAL_for="for"=39
LITERAL_goto="goto"=40
LITERAL_continue="continue"=41
LITERAL_break="break"=42
LITERAL_return="return"=43
LITERAL_case="case"=44
LITERAL_default="default"=45
LITERAL_if="if"=46
LITERAL_else="else"=47
LITERAL_switch="switch"=48
DIV_ASSIGN=49
PLUS_ASSIGN=50
MINUS_ASSIGN=51
STAR_ASSIGN=52
MOD_ASSIGN=53
RSHIFT_ASSIGN=54
LSHIFT_ASSIGN=55
BAND_ASSIGN=56
BOR_ASSIGN=57
BXOR_ASSIGN=58
QUESTION=59
LOR=60
LAND=61
BOR=62
BXOR=63
BAND=64
EQUAL=65
NOT_EQUAL=66
LT=67
LTE=68
GT=69
GTE=70
LSHIFT=71
RSHIFT=72
PLUS=73
MINUS=74
DIV=75
MOD=76
INC=77
DEC=78
LITERAL_sizeof="sizeof"=79
BNOT=80
LNOT=81
PTR=82
DOT=83
CharLiteral=84
StringLiteral=85
IntOctalConst=86
LongOctalConst=87
UnsignedOctalConst=88
IntIntConst=89
LongIntConst=90
UnsignedIntConst=91
IntHexConst=92
LongHexConst=93
UnsignedHexConst=94
FloatDoubleConst=95
DoubleDoubleConst=96
LongDoubleConst=97
NTypedefName=98
NInitDecl=99
NDeclarator=100
NStructDeclarator=101
NDeclaration=102
NCast=103
NPointerGroup=104
NExpressionGroup=105
NFunctionCallArgs=106
NNonemptyAbstractDeclarator=107
NInitializer=108
NStatementExpr=109
NEmptyExpression=110
NParameterTypeList=111
NFunctionDef=112
NCompoundStatement=113
NParameterDeclaration=114
NCommaExpr=115
NUnaryExpr=116
NLabel=117
NPostfixExpr=118
NRangeExpr=119
NStringSeq=120
NInitializerElementLabel=121
NLcurlyInitializer=122
NAsmAttribute=123
NGnuAsmExpr=124
NTypeMissing=125
Vocabulary=126
Whitespace=127
Comment=128
CPPComment=129
PREPROC_DIRECTIVE("a line directive")=130
Space=131
LineDirective=132
BadStringLiteral=133
Escape=134
Digit=135
LongSuffix=136
UnsignedSuffix=137
FloatSuffix=138
Exponent=139
Number=140
LITERAL___label__="__label__"=141
LITERAL_inline="inline"=142
LITERAL_byte="byte"=143
LITERAL_boolean="boolean"=144
LITERAL_Servo="Servo"=145
LITERAL_Wire="Wire"=146
LITERAL_typeof="typeof"=147
LITERAL___complex="__complex"=148
LITERAL___attribute="__attribute"=149
LITERAL___alignof="__alignof"=150
LITERAL___real="__real"=151
LITERAL___imag="__imag"=152

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,150 +0,0 @@
// this is a whitespace and other invisible token torture test for the ANTLR-based
// preprocessor. edit pde.properties and set "editor.save_build_files" to true.
// then, build this in processing. next, use
//
// diff -u --strip-trailing-cr \
// work/sketchbook/default/whitespace_test/whitespace_test.pde \
// work/lib/build/MyDemo.java
//
// to compare the files before and after preprocessing. There should not be
// any differences.
import // comment test
java.io.*;
// comment 1
public class // post-class comment
// comment2
MyDemo extends BApplet implements // foo
java.lang. // bar
Cloneable {
//argh
public // foo
String // bar
fff = /*rheet */ "stuff";
static /*a*/ {
/*foo*/
/*bar*/
six = 6;
} /* b*/
static /*a*/ final /*b*/ int six;
void setup()
{
size(200, 200);
background(255);
this . fff = /* ook */ (String)/*foo*/"yo";
rectMode(CENTER_DIAMETER); // comment 1a
noStroke();
fill(255, 204, 0);
int q = /*a*/ - /*b*/ 1;
boolean c = /*a*/ ! /*b*/ true;
}
int foo() /*a*/ throws /*b*/ java.lang.Exception /*c*/
{
int b = 7;
switch /*a*/ ( /*b*/ b /*c*/ ) {
case /*d*/ 1 /*e*/: /*f*/
int c=9;
/*g*/
break; /*h*/
default /*i*/ :
int d=9;
break;
}
try { /* qq */
loop(); /* rr */
} catch /*ss*/ (java.lang.Exception ex) /*tt*/ {
b = 8; /*tut*/
throw /*utu*/ ex;
} /*uu*/ finally /*vv*/ {
b = 9;
} /*ww*/
b /*aaa*/ = /*bbb*/ true /*ccc*/ ? /*ddd*/ 0 /*eee*/
: /* fff*/ 1 /*ggg*/;
return /*a*/ 5 /*b*/;
}
// comment 2
void loop()
{
int arr1 /* VVV */ [ /* XXX */] /*YYY*/ ;
int[] arr2 = { /*a*/ 2, 3 /*b*/ } /*c*/ ;
for /*a*/ (/*b*/ int j=0 /*c*/; /*d*/ j<2/*e*/ ; /*f*/ j++ /*g*/)
/*h*/
arr2[1] = 6;
/*foo*/
;
/*bar*/
rect(width-mouseX, height-mouseY, 50, 50);
rect(mouseX, mouseY, 50, 50);
if (/*a*/ arr2[1] == 6/*b*/) {
/*c*/
int d=7;
} /*d*/else /*e*/{
int e=8;
/*f*/
}
int f;
if (/*aa*/ arr2[1] ==6 /*bb*/ )
/*cc*/
f=8; /*dd*/
else /*ee*/
f=10; /*ff*/
while ( /*aaa*/ f < 15) /*bbb*/ {
f ++;
} /*ggg*/
do /* aaaa */ {
f++;
} /*bbbb*/ while /*cccc*/ ( /*a*/ - /*b*/ 20 > f) /*dddd*/;
f = 2 * 3 + 4;
f = ( 2 * 3 ) + 4 + /*aa*/ -/*bb*/1;
f = 2 * ( 3 + 4 ) ;
fff = /*a*/ new /*b*/ String(/*c*/"foo"/*d*/) /*e*/;
int arr3[] = /*a*/ new /*b*/ int/*c*/[/*d*/] /*e*/ {1/*f*/,2};
int arr4[][] = new /*a*/int/*b*/[1][2]/*c*/;
}
class Shoe
{
Shoe(String brand)
{
println(brand);
}
}
class NikeAir extends Shoe
{
NikeAir()
{
/*a*/ super /*b*/ ( /*c*/ "Nike" /*d*/ ) /*e*/ ;
/*aa*/ ( /*bb*/ new /*cc*/ MyDemo /*dd*/ (/*ee*/)/*ff*/)/*gg*/./*hh*/super/*ii*/(/*jj*/5/*kk*/);
}
}
}