예제 #1
0
func (my *Parser) parse() {
	msg.Cout("{parsing}")
	// my.wr.puts(syntax.C_INCLUDE)

	for my.rd.tell() != NULL {
		my.dive()
	}
}
예제 #2
0
func (my *Parser) preprocess() {
	msg.Cout("{preprocessing}")

	my.wr.puts(syntax.C_INCLUDE)
	my.skipIncluded()

	for c := my.rd.tell(); c != NULL; c = my.rd.tell() {
		switch {
		case isComment(c, my.rd.fpeek()):
			my.insertSemicolon()
			my.appendComment()

		case c == '`' || isQuote(c):
			my.appendBetween(c)

		case c == '#':
			my.appendMacro()

		case isLetter(c):
			my.escapeIdentifier()

		case c == sys.NEWLINE:
			my.insertSemicolon()
			my.pushNewline()

		default:
			my.wr.putc(my.rd.getc())
		}
	}

	if my.rd.tell() != sys.NEWLINE {
		if sys.OS == sys.WINDOWS {
			my.wr.putc('\r')
		}

		my.wr.putc('\n')
	}
}
예제 #3
0
func (my *Parser) assemble() {
	msg.Cout("{assembling}")
	println("Buf size at the end:", cap(*my.wr.wdest))
	println("Space used:", len(my.wr.extract()))
}