Skip to content

Commit

Permalink
checkin for r
Browse files Browse the repository at this point in the history
  • Loading branch information
geertjan committed Mar 23, 2014
1 parent c4ac1f5 commit f04bf4d
Show file tree
Hide file tree
Showing 23 changed files with 2,501 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
/RNb/nbproject/private/
/RNb/build/
/RNb/Options/build/
/RNb/Execution/build/
/RNb/Completion/build/
/RNb/Palette/build/
/RNb/Navigator/build/
/RNb/Language/build/
/RNb/Project/build/
/RNb/Analyzer/nbproject/private/
8 changes: 8 additions & 0 deletions build.xml
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="org.netbeans.lexer" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project org.netbeans.lexer.</description>
<import file="nbproject/build-impl.xml"/>
</project>
6 changes: 6 additions & 0 deletions manifest.mf
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.lexer
OpenIDE-Module-Layer: org/netbeans/lexer/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/lexer/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0

45 changes: 45 additions & 0 deletions nbproject/build-impl.xml
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<project name="org.netbeans.lexer-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
<property file="${suite.dir}/nbproject/platform.properties"/>
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>
<import file="${harness.dir}/build.xml"/>
</project>
8 changes: 8 additions & 0 deletions nbproject/genfiles.properties
@@ -0,0 +1,8 @@
build.xml.data.CRC32=a9c1e28d
build.xml.script.CRC32=4ff1090d
build.xml.stylesheet.CRC32=a56c6a5b@2.56.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=a9c1e28d
nbproject/build-impl.xml.script.CRC32=f49e8f64
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.56.1
2 changes: 2 additions & 0 deletions nbproject/project.properties
@@ -0,0 +1,2 @@
javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
78 changes: 78 additions & 0 deletions nbproject/project.xml
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>org.netbeans.lexer</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>org.netbeans.libs.antlr3.runtime</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.12.1.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>3</release-version>
<specification-version>1.71.2.5.21.40</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.extexecution</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
<specification-version>1.36.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.lexer</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
<specification-version>1.49.3.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.parsing.api</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.62.2.6</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.spi.editor.hints</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>0-1</release-version>
<specification-version>1.28.3.7.40</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.filesystems</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.5.1</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<public-packages/>
<class-path-extension>
<runtime-relative-path>ext/antlr-4.0-complete.jar</runtime-relative-path>
<binary-origin>release/modules/ext/antlr-4.0-complete.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
1 change: 1 addition & 0 deletions nbproject/suite.properties
@@ -0,0 +1 @@
suite.dir=${basedir}/..
Binary file added release/modules/ext/antlr-4.0-complete.jar
Binary file not shown.
164 changes: 164 additions & 0 deletions src/org/netbeans/lexer/AntlrCharStream.java
@@ -0,0 +1,164 @@
package org.netbeans.lexer;

import java.util.ArrayList;
import java.util.List;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.misc.Interval;
import org.netbeans.spi.lexer.LexerInput;

public class AntlrCharStream implements CharStream {

private class CharStreamState {

int index;
int line;
int charPositionInLine;
}

private int line = 1;
private int charPositionInLine = 0;
private LexerInput input;
private String name;
private int index = 0;
private List<CharStreamState> markers;
private int markDepth = 0;
private int lastMarker;
private boolean ignoreCase = false;

public AntlrCharStream(LexerInput input, String name) {
this.input = input;
this.name = name;
}

public AntlrCharStream(LexerInput input, String name, boolean ignoreCase) {
this.input = input;
this.name = name;
this.ignoreCase = ignoreCase;
}

public String substring(int start, int stop) {
return input.readText(start, stop).toString();
}

@Override
public String getText(Interval intrvl) {
return null;
}

public int LT(int i) {
return LA(i);
}

public int getLine() {
return line;
}

public void setLine(int line) {
this.line = line;
}

public void setCharPositionInLine(int pos) {
this.charPositionInLine = pos;
}

public int getCharPositionInLine() {
return charPositionInLine;
}

@Override
public void consume() {
int c = input.read();
index++;
charPositionInLine++;

if (c == '\n') {
line++;
charPositionInLine = 0;
}
}

@Override
public int LA(int i) {
if (i == 0) {
return 0; // undefined
}

int c = 0;
for (int j = 0; j < i; j++) {
c = read();
}
backup(i);
return c;
}

@Override
public int mark() {
if (markers == null) {
markers = new ArrayList<CharStreamState>();
markers.add(null); // depth 0 means no backtracking, leave blank
}
markDepth++;
CharStreamState state = null;
if (markDepth >= markers.size()) {
state = new CharStreamState();
markers.add(state);
} else {
state = markers.get(markDepth);
}
state.index = index;
state.line = line;
state.charPositionInLine = charPositionInLine;
lastMarker = markDepth;

return markDepth;
}

@Override
public void release(int i) {
markDepth = i;
markDepth--;
}

@Override
public int index() {
return index;
}

@Override
public void seek(int i) {
if (index < this.index) {
backup(this.index - index);
this.index = index; // just jump; don't update stream state (line, ...)
return;
}

// seek forward, consume until p hits index
while (this.index < index) {
consume();
}
}

@Override
public int size() {
return -1;
}

@Override
public String getSourceName() {
return name;
}

private int read() {
int result = input.read();
if (result == LexerInput.EOF) {
result = CharStream.EOF;
}

return result;
}

private void backup(int count) {
input.backup(count);
}

}
9 changes: 9 additions & 0 deletions src/org/netbeans/lexer/Bundle.properties
@@ -0,0 +1,9 @@
OpenIDE-Module-Name=Analyser
text/x-r=R
identifier=Identifier
keyword=Keyword
type=Type
whitespace=Whitespace
string=String
operator=Operator
number=Number
18 changes: 18 additions & 0 deletions src/org/netbeans/lexer/FontAndColors.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontscolors PUBLIC "-//NetBeans//DTD Editor Fonts and Colors settings 1.1//EN" "http://www.netbeans.org/dtds/EditorFontsColors-1_1.dtd">

<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<fontscolors>
<fontcolor name="identifier" default="identifier"/>
<fontcolor name="keyword" default="keyword"/>
<fontcolor name="whitespace" default="whitespace"/>
<fontcolor name="type" default="type"/>
<fontcolor name="operator" default="operator"/>
<fontcolor name="string" default="string"/>
<fontcolor name="number" default="number"/>
</fontscolors>

0 comments on commit f04bf4d

Please sign in to comment.