Skip to content

Commit fb8f117

Browse files
committed
Sync from Google's internal repo.
Two main things were done: 1) g3doc/rune_reference.md had a substantial update. 2) A PEG parser was written in Rune. The new PEG parser is able to parse all Rune files in this repo, other than two which intentially have syntax errors for testing.
1 parent 9a89bd8 commit fb8f117

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2520
-988
lines changed

bind/bind.c

+14
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,19 @@ void deReportEvents(void) {
628628
}
629629
}
630630

631+
// Bind exportllib functions, even if they are not called internally.
632+
void createExportLibSignatures(void) {
633+
deFunction function;
634+
deForeachRootFunction(deTheRoot, function) {
635+
if (deFunctionGetLinkage(function) == DE_LINK_LIBCALL &&
636+
deFunctionGetUniquifiedSignature(function) == deSignatureNull) {
637+
deSignature signature = deCreateFullySpecifiedSignature(function);
638+
deSignatureSetInstantiated(signature, true);
639+
deQueueSignature(signature);
640+
}
641+
} deEndRootFunction;
642+
}
643+
631644
// Bind expressions everywhere.
632645
void deBind(void) {
633646
deBlock rootBlock = deRootGetBlock(deTheRoot);
@@ -636,6 +649,7 @@ void deBind(void) {
636649
deDatatypeArrayAlloc(), deFunctionGetLine(mainFunc));
637650
deSignatureSetInstantiated(mainSignature, true);
638651
deQueueSignature(mainSignature);
652+
createExportLibSignatures();
639653
deBindAllSignatures();
640654
destroyUnusedTemplateContents();
641655
deReportEvents();

bind/bindexpr.c

+3
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,9 @@ static void bindNamedParameter(deBlock scopeBlock, deExpression expression) {
16311631
if (deVariableGetType(var) != DE_VAR_PARAMETER) {
16321632
deExprError(expression, "Variable %s is a local variable, not a parameter", utSymGetName(paramName));
16331633
}
1634+
if (ident != deIdentNull) {
1635+
deIdentRemoveExpression(ident, paramNameExpression);
1636+
}
16341637
deIdentAppendExpression(ident, paramNameExpression);
16351638
}
16361639

bootstrap/database/bigint.rn

+4-4
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ unittest testUnaryOperators {
442442
assert -Bigint(123i256) == Bigint(-123i256)
443443
println -Bigint(12345i32)
444444
// Test truncating negation's one exceptional input.
445-
assert !-Bigint(!-128i8) == Bigint(!-128i8)
445+
assert !-Bigint(!<i8>128u8) == Bigint(!<i8>128u8)
446446
assert !-Bigint(-127i8) == Bigint(127i8)
447447
println (~Bigint(0x55aaau20)).toStringInBase(16u32)
448448
assert ~Bigint(0x55aaau20) == Bigint(0xaa555u20);
@@ -453,9 +453,9 @@ unittest testShiftOperators {
453453
a = Bigint(0xdeadbeefu32)
454454
assert a >> 16u32 == Bigint(0xdeadu32)
455455
assert a << 4u32 == Bigint(0xeadbeef0u32)
456-
b = Bigint(0xdeadbeefi32)
457-
assert b >> 16u32 == Bigint(0xffffdeadi32)
458-
assert b << 4u32 == Bigint(0xeadbeef0i32)
456+
b = Bigint(!<i32>0xdeadbeefu32)
457+
assert b >> 16u32 == Bigint(!<i32>0xffffdeadu32)
458+
assert b << 4u32 == Bigint(!<i32>0xeadbeef0u32)
459459
}
460460

461461
// Test rotation operators.

bootstrap/database/location.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Location(self, filepath: Filepath, pos:u32, len: u32, line: u32) {
4242
assert !isnull(filepath)
4343
path = filepath!.getRelativePath()
4444
if path.length() > 0 {
45-
println "File %s, line %u: %s" % (path, self.line, msg)
45+
println "%s:%u: %s" % (path, self.line, msg)
4646
}
4747
if filepath!.text.length() > 0 {
4848
self.printLocationAndCarots()

bootstrap/database/signature.rn

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use class
1615
use filepath
1716
use function
1817
use statement

bootstrap/parsegen/.exrc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
if &cp | set nocp | endif
2+
let s:cpo_save=&cpo
3+
set cpo&vim
4+
xmap gx <Plug>NetrwBrowseXVis
5+
nmap gx <Plug>NetrwBrowseX
6+
xnoremap <silent> <Plug>NetrwBrowseXVis :call netrw#BrowseXVis()
7+
nnoremap <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX()))
8+
map <F4> :set spell!|:echo "Spell check: " . strpart("OffOn", 3 * &spell, 3)
9+
let &cpo=s:cpo_save
10+
unlet s:cpo_save
11+
set backspace=indent,eol,start
12+
set expandtab
13+
set fileencodings=ucs-bom,utf-8,default,latin1
14+
set helplang=en
15+
set hidden
16+
set ignorecase
17+
set nomodeline
18+
set printoptions=paper:letter
19+
set ruler
20+
set shiftwidth=2
21+
set showcmd
22+
set showmatch
23+
set smartcase
24+
set smartindent
25+
set spellfile=~/.words.utf8.add
26+
set spellsuggest=best,10
27+
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
28+
set tabstop=2
29+
" vim: set ft=vim :

bootstrap/parsegen/Makefile

+6-9
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@
1515
RUNE=../../rune
1616
RNFLAGS=-g -r ..
1717

18-
RUNE_TESTS=char lexer parser token keytab
18+
RUNE_TESTS=char lexer token keytab pegparser
1919

20-
all: runtests parsergen
20+
all: runtests
2121

2222
runtests: $(RUNE_TESTS)
2323
for test in $(RUNE_TESTS); do "./$$test"; done
2424

25-
parsergen: parsergen.rn
26-
$(RUNE) $(RNFLAGS) parsergen.rn
27-
28-
parser: parser.rn lexer.rn char.rn
29-
$(RUNE) $(RNFLAGS) parser.rn
30-
3125
char: char.rn
3226
$(RUNE) $(RNFLAGS) char.rn
3327

@@ -38,7 +32,10 @@ token: token.rn
3832
$(RUNE) $(RNFLAGS) token.rn
3933

4034
keytab: keytab.rn
41-
$(RUNE) -g keytab.rn
35+
$(RUNE) $(RNFLAGS) keytab.rn
36+
37+
pegparser: pegparser.rn lexer.rn token.rn char.rn keytab.rn
38+
$(RUNE) $(RNFLAGS) pegparser.rn
4239

4340
clean:
4441
rm -f $(RUNE_TESTS) *.ll parsergen

bootstrap/parsegen/README.md

-8
This file was deleted.

bootstrap/parsegen/char.rn

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ unittest overlong {
234234
char = getChar("\xe0\x80\x80", 0u32)
235235
assert !char.valid
236236
// Overlong encoding of €.
237-
char = getChar("\xf0\82\82\ac", 0u32)
237+
char = getChar("\xf0\x82\x82\xac", 0u32)
238238
assert !char.valid
239239
}
240240

bootstrap/parsegen/iedge.rn

-22
This file was deleted.

bootstrap/parsegen/item.rn

-30
This file was deleted.

bootstrap/parsegen/itemset.rn

-21
This file was deleted.

bootstrap/parsegen/keytab.rn

+20
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,30 @@ class Keytab(self) {
1818
func lookup(self, name: string) -> Keyword? {
1919
return self.findKeyword(Sym.new(name))
2020
}
21+
22+
// Only build a new keyword if it does not yet exist.
23+
func new(self:Keytab, name: string) -> Keyword {
24+
sym = Sym.new(name)
25+
oldKeyword = self.findKeyword(sym)
26+
if !isnull(oldKeyword) {
27+
return oldKeyword!
28+
}
29+
return Keyword(self, name)
30+
}
31+
32+
func setKeywordNums(self) -> u32 {
33+
num = 0u32
34+
for keyword in self.keywords() {
35+
keyword.num = num
36+
num += 1
37+
}
38+
return num
39+
}
2140
}
2241

2342
class Keyword(self, keytab: Keytab, name: string) {
2443
self.sym = Sym.new(name)
44+
self.num = 0u32 // Set after all rules are parsed.
2545
keytab.insertKeyword(self)
2646
}
2747

0 commit comments

Comments
 (0)