From adc7bdf2ff3bb2ae8d0d94d0587617d2c17fd08d Mon Sep 17 00:00:00 2001 From: chrehall68 Date: Mon, 11 Nov 2024 17:00:32 -0800 Subject: [PATCH 1/4] don't export internal functions --- server/internal/lang/parser.go | 244 ++++++++++++++++----------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/server/internal/lang/parser.go b/server/internal/lang/parser.go index b5401d5..98561c0 100644 --- a/server/internal/lang/parser.go +++ b/server/internal/lang/parser.go @@ -204,7 +204,7 @@ func (p *Parser) isEOF(tokens []Token, pos int) bool { // ============================== // returned position is the position after the rbracket -func (p *Parser) ParseRangeNode(tokens []Token, pos int) (result RangeNode, newPos int, err error) { +func (p *Parser) parseRangeNode(tokens []Token, pos int) (result RangeNode, newPos int, err error) { pos, err = p.checkToken("range node", []string{"lbracket"}, pos, tokens) if err != nil { return @@ -212,7 +212,7 @@ func (p *Parser) ParseRangeNode(tokens []Token, pos int) (result RangeNode, newP pos++ // now take the from - fromNode, pos, err := p.ParseExpression(tokens, pos) + fromNode, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -226,7 +226,7 @@ func (p *Parser) ParseRangeNode(tokens []Token, pos int) (result RangeNode, newP pos++ // take the to - toNode, pos, err := p.ParseExpression(tokens, pos) + toNode, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -243,14 +243,14 @@ func (p *Parser) ParseRangeNode(tokens []Token, pos int) (result RangeNode, newP } // returned position is the position after the rbracket -func (p *Parser) ParseIndexNode(tokens []Token, pos int) (result IndexNode, newPos int, err error) { +func (p *Parser) parseIndexNode(tokens []Token, pos int) (result IndexNode, newPos int, err error) { pos, err = p.checkToken("index node", []string{"lbracket"}, pos, tokens) if err != nil { return } pos++ - indexNode, pos, err := p.ParseExpression(tokens, pos) + indexNode, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -266,7 +266,7 @@ func (p *Parser) ParseIndexNode(tokens []Token, pos int) (result IndexNode, newP } // -> LBRACKET [COLON ] RBRACKET -func (p *Parser) ParseSelectorNode(tokens []Token, pos int) (result SelectorNode, newPos int, err error) { +func (p *Parser) parseSelectorNode(tokens []Token, pos int) (result SelectorNode, newPos int, err error) { // check for lbracket pos, err = p.checkToken("selector node", []string{"lbracket"}, pos, tokens) if err != nil { @@ -274,7 +274,7 @@ func (p *Parser) ParseSelectorNode(tokens []Token, pos int) (result SelectorNode } pos++ - firstNode, pos, err := p.ParseExpression(tokens, pos) + firstNode, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -286,7 +286,7 @@ func (p *Parser) ParseSelectorNode(tokens []Token, pos int) (result SelectorNode pos = potentialPos pos++ - secondNode, potentialPos, e := p.ParseExpression(tokens, pos) + secondNode, potentialPos, e := p.parseExpression(tokens, pos) if e != nil { err = e return @@ -326,7 +326,7 @@ func (p *Parser) parseSized(tokens []Token, pos int) (result SizedValueNode, new pos++ // now take the values - sizedNode, potentialPos, e := p.ParseSizedValueNode(tokens, pos) + sizedNode, potentialPos, e := p.parseSizedValueNode(tokens, pos) if e != nil { // there must be at least one value err = e @@ -342,7 +342,7 @@ func (p *Parser) parseSized(tokens []Token, pos int) (result SizedValueNode, new if e != nil { break } - sizedNode, potentialPos, e = p.ParseSizedValueNode(tokens, potentialPos+1) + sizedNode, potentialPos, e = p.parseSizedValueNode(tokens, potentialPos+1) } // take the rcurl @@ -355,7 +355,7 @@ func (p *Parser) parseSized(tokens []Token, pos int) (result SizedValueNode, new return } -func (p *Parser) ParseSizedValueNode(tokens []Token, pos int) (result SizedValueNode, newPos int, err error) { +func (p *Parser) parseSizedValueNode(tokens []Token, pos int) (result SizedValueNode, newPos int, err error) { // try just taking a value sizedNode, potentialPos, e := p.parseSized(tokens, pos) if e == nil { @@ -364,7 +364,7 @@ func (p *Parser) ParseSizedValueNode(tokens []Token, pos int) (result SizedValue pos = potentialPos } else { // it wasn't - valueNode, potentialPos, e := p.ParseValueNode(tokens, pos) + valueNode, potentialPos, e := p.parseValueNode(tokens, pos) if e != nil { err = e return @@ -377,7 +377,7 @@ func (p *Parser) ParseSizedValueNode(tokens []Token, pos int) (result SizedValue } // -> | SIGNED LPAREN RPAREN -func (p *Parser) ParseSigned(tokens []Token, pos int) (result SizedValueNode, newPos int, err error) { +func (p *Parser) parseSigned(tokens []Token, pos int) (result SizedValueNode, newPos int, err error) { potentialPos, e := p.checkToken("signed", []string{"signed"}, pos, tokens) if e == nil { // it was signed @@ -391,7 +391,7 @@ func (p *Parser) ParseSigned(tokens []Token, pos int) (result SizedValueNode, ne pos++ // take sized value - result, pos, err = p.ParseSizedValueNode(tokens, pos) + result, pos, err = p.parseSizedValueNode(tokens, pos) if err != nil { return } @@ -405,14 +405,14 @@ func (p *Parser) ParseSigned(tokens []Token, pos int) (result SizedValueNode, ne } else { // just a regular sized value - result, pos, err = p.ParseSizedValueNode(tokens, pos) + result, pos, err = p.parseSizedValueNode(tokens, pos) } newPos = pos return } // returned position is the position after the value node -func (p *Parser) ParseValueNode(tokens []Token, pos int) (result ValueNode, newPos int, err error) { +func (p *Parser) parseValueNode(tokens []Token, pos int) (result ValueNode, newPos int, err error) { // -> [TILDE| - ] (LITERAL|( { DOT })|FUNCLITERAL) { } // get optional tilde or minus @@ -451,25 +451,25 @@ func (p *Parser) ParseValueNode(tokens []Token, pos int) (result ValueNode, newP } // and any selectors - selectorNode, potentialPos, e := p.ParseSelectorNode(tokens, pos) + selectorNode, potentialPos, e := p.parseSelectorNode(tokens, pos) for e == nil { pos = potentialPos result.Selectors = append(result.Selectors, selectorNode) - selectorNode, potentialPos, e = p.ParseSelectorNode(tokens, pos) + selectorNode, potentialPos, e = p.parseSelectorNode(tokens, pos) } newPos = pos return } -func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newPos int, err error) { +func (p *Parser) parseExpression(tokens []Token, pos int) (result ExprNode, newPos int, err error) { // -> ( | LPAREN RPAREN) [(OPERATOR|COMPARATOR) ] [ QUESTION COLON ] potentialPos, e := p.checkToken("expression", []string{"lparen"}, pos, tokens) if e == nil { // nested expression pos = potentialPos + 1 - result, pos, err = p.ParseExpression(tokens, pos) + result, pos, err = p.parseExpression(tokens, pos) if err != nil { return } @@ -481,7 +481,7 @@ func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newP pos++ } else { // just a value - value, potentialPos, e := p.ParseSigned(tokens, pos) + value, potentialPos, e := p.parseSigned(tokens, pos) if e != nil { err = e return @@ -499,7 +499,7 @@ func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newP pos++ // get the right expression - tmp, potentialPos, e := p.ParseExpression(tokens, pos) + tmp, potentialPos, e := p.parseExpression(tokens, pos) if e != nil { err = e return @@ -513,7 +513,7 @@ func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newP if e == nil { // get the true expression pos = potentialPos + 1 - tmp, potentialPos, e := p.ParseExpression(tokens, pos) + tmp, potentialPos, e := p.parseExpression(tokens, pos) if e != nil { err = e return @@ -529,7 +529,7 @@ func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newP pos++ // get the false expression - tmp, potentialPos, e = p.ParseExpression(tokens, pos) + tmp, potentialPos, e = p.parseExpression(tokens, pos) if e != nil { err = e return @@ -542,7 +542,7 @@ func (p *Parser) ParseExpression(tokens []Token, pos int) (result ExprNode, newP return } -func (p *Parser) ParseArgument(tokens []Token, pos int) (result ArgumentNode, newPos int, err error) { +func (p *Parser) parseArgument(tokens []Token, pos int) (result ArgumentNode, newPos int, err error) { // dot for named parameter, identifier/lcurcly/literal for value pos, err = p.checkToken("argument", []string{"dot", "identifier", "lcurl", "literal"}, pos, tokens) if err != nil { @@ -566,7 +566,7 @@ func (p *Parser) ParseArgument(tokens []Token, pos int) (result ArgumentNode, ne pos++ // get value - value, potentialPos, e := p.ParseExpression(tokens, pos) + value, potentialPos, e := p.parseExpression(tokens, pos) if e == nil { // success! result.Value = value @@ -586,7 +586,7 @@ func (p *Parser) ParseArgument(tokens []Token, pos int) (result ArgumentNode, ne return } else { // just a value - value, potentialPos, e := p.ParseExpression(tokens, pos) + value, potentialPos, e := p.parseExpression(tokens, pos) if e == nil { // success! result.Value = value @@ -599,12 +599,12 @@ func (p *Parser) ParseArgument(tokens []Token, pos int) (result ArgumentNode, ne return } } -func (p *Parser) ParseArguments(tokens []Token, pos int) (result []ArgumentNode, newPos int, err error) { +func (p *Parser) parseArguments(tokens []Token, pos int) (result []ArgumentNode, newPos int, err error) { // arguments is just a bunch of argument nodes // so we take our first argument and then take any extras separated by commas // get the first argument - argument, potentialPos, e := p.ParseArgument(tokens, pos) + argument, potentialPos, e := p.parseArgument(tokens, pos) if e == nil { // success! result = append(result, argument) @@ -614,7 +614,7 @@ func (p *Parser) ParseArguments(tokens []Token, pos int) (result []ArgumentNode, // now take the rest potentialPos, e = p.checkToken("arguments", []string{"comma"}, pos, tokens) for e == nil { - argument, potentialPos, e = p.ParseArgument(tokens, potentialPos+1) // potentialPos was position of comma + argument, potentialPos, e = p.parseArgument(tokens, potentialPos+1) // potentialPos was position of comma if e == nil { // success! result = append(result, argument) @@ -629,7 +629,7 @@ func (p *Parser) ParseArguments(tokens []Token, pos int) (result []ArgumentNode, newPos = pos return } -func (p *Parser) ParseModuleApplication(tokens []Token, pos int) (result ModuleApplicationNode, newPos int, err error) { +func (p *Parser) parseModuleApplication(tokens []Token, pos int) (result ModuleApplicationNode, newPos int, err error) { // module name pos, err = p.checkToken("module application", []string{"identifier"}, pos, tokens) if err != nil { @@ -646,7 +646,7 @@ func (p *Parser) ParseModuleApplication(tokens []Token, pos int) (result ModuleA } // might have a gate range - rangeNode, potentialPos, e := p.ParseRangeNode(tokens, pos) + rangeNode, potentialPos, e := p.parseRangeNode(tokens, pos) if e == nil { result.Range = &rangeNode pos = potentialPos @@ -660,7 +660,7 @@ func (p *Parser) ParseModuleApplication(tokens []Token, pos int) (result ModuleA pos++ // get arguments - arguments, potentialPos, e := p.ParseArguments(tokens, pos) + arguments, potentialPos, e := p.parseArguments(tokens, pos) if e == nil { // success! result.Arguments = arguments @@ -687,7 +687,7 @@ func (p *Parser) ParseModuleApplication(tokens []Token, pos int) (result ModuleA return } -func (p *Parser) ParseVariableNode(tokens []Token, pos int) (result VariableNode, newPos int, err error) { +func (p *Parser) parseVariableNode(tokens []Token, pos int) (result VariableNode, newPos int, err error) { // identifier optionally followed by a range pos, err = p.checkToken("variable", []string{"identifier"}, pos, tokens) if err != nil { @@ -697,7 +697,7 @@ func (p *Parser) ParseVariableNode(tokens []Token, pos int) (result VariableNode pos++ // now try taking the range; it's ok if it fails since it's optional - rangeNode, potentialPos, e := p.ParseRangeNode(tokens, pos) + rangeNode, potentialPos, e := p.parseRangeNode(tokens, pos) if e == nil { // success! result.Range = &rangeNode @@ -706,7 +706,7 @@ func (p *Parser) ParseVariableNode(tokens []Token, pos int) (result VariableNode newPos = pos return } -func (p *Parser) ParseAssignmentNodeWithoutSemicolon(tokens []Token, pos int) (result AssignmentNode, newPos int, err error) { +func (p *Parser) parseAssignmentNodeWithoutSemicolon(tokens []Token, pos int) (result AssignmentNode, newPos int, err error) { // [ASSIGN] [] (EQUAL|<=) // TODO - get the expr, not just a value potentialPos, e := p.checkToken("assignment", []string{"assign"}, pos, tokens) @@ -724,7 +724,7 @@ func (p *Parser) ParseAssignmentNodeWithoutSemicolon(tokens []Token, pos int) (r pos++ // now try taking the index; it's ok if it fails since it's optional - indexNode, potentialPos, e := p.ParseIndexNode(tokens, pos) + indexNode, potentialPos, e := p.parseIndexNode(tokens, pos) if e == nil { // success! result.Index = &indexNode @@ -745,7 +745,7 @@ func (p *Parser) ParseAssignmentNodeWithoutSemicolon(tokens []Token, pos int) (r pos++ // get the value - valueNode, potentialPos, e := p.ParseExpression(tokens, pos) + valueNode, potentialPos, e := p.parseExpression(tokens, pos) if e == nil { // success! result.Value = valueNode @@ -758,9 +758,9 @@ func (p *Parser) ParseAssignmentNodeWithoutSemicolon(tokens []Token, pos int) (r newPos = pos return } -func (p *Parser) ParseAssignmentNode(tokens []Token, pos int) (result AssignmentNode, newPos int, err error) { +func (p *Parser) parseAssignmentNode(tokens []Token, pos int) (result AssignmentNode, newPos int, err error) { // SEMICOLON - result, pos, err = p.ParseAssignmentNodeWithoutSemicolon(tokens, pos) + result, pos, err = p.parseAssignmentNodeWithoutSemicolon(tokens, pos) if err != nil { return } @@ -775,7 +775,7 @@ func (p *Parser) ParseAssignmentNode(tokens []Token, pos int) (result Assignment return } -func (p *Parser) ParseTypeNode(tokens []Token, pos int) (result TypeNode, newPos int, err error) { +func (p *Parser) parseTypeNode(tokens []Token, pos int) (result TypeNode, newPos int, err error) { // TYPE [] pos, err = p.checkToken("type", []string{"type"}, pos, tokens) if err != nil { @@ -785,7 +785,7 @@ func (p *Parser) ParseTypeNode(tokens []Token, pos int) (result TypeNode, newPos pos++ // now try taking the range; it's ok if it fails since it's optional - rangeNode, potentialPos, e := p.ParseRangeNode(tokens, pos) + rangeNode, potentialPos, e := p.parseRangeNode(tokens, pos) if e == nil { // success! result.VectorRange = &rangeNode @@ -795,11 +795,11 @@ func (p *Parser) ParseTypeNode(tokens []Token, pos int) (result TypeNode, newPos return } -func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result DeclarationNode, newPos int, err error) { +func (p *Parser) parseDeclarationNode(tokens []Token, pos int) (result DeclarationNode, newPos int, err error) { // -> EQUAL { COMMA EQUAL } SEMICOLON // | { COMMA } SEMICOLON - typeNode, potentialPos, e := p.ParseTypeNode(tokens, pos) + typeNode, potentialPos, e := p.parseTypeNode(tokens, pos) if e != nil { err = e return @@ -808,7 +808,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati pos = potentialPos // get the variable - variableNode, potentialPos, e := p.ParseVariableNode(tokens, pos) + variableNode, potentialPos, e := p.parseVariableNode(tokens, pos) if e != nil { err = e return @@ -820,7 +820,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati potentialPos, e = p.checkToken("declaration", []string{"equal"}, pos, tokens) if e == nil { // it's an equal, so there's a value - valueNode, potentialPos, e := p.ParseExpression(tokens, potentialPos+1) + valueNode, potentialPos, e := p.parseExpression(tokens, potentialPos+1) if e == nil { result.Values = append(result.Values, valueNode) pos = potentialPos @@ -836,7 +836,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati // it's a comma, so there's more variables for e == nil { // get var - variableNode, pos, err = p.ParseVariableNode(tokens, potentialPos+1) + variableNode, pos, err = p.parseVariableNode(tokens, potentialPos+1) if err != nil { return } @@ -850,7 +850,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati pos++ // get value - valueNode, pos, err = p.ParseExpression(tokens, pos) + valueNode, pos, err = p.parseExpression(tokens, pos) if err != nil { return } @@ -868,7 +868,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati pos = potentialPos // it's a comma, so there's more variables for e == nil { - variableNode, potentialPos, e = p.ParseVariableNode(tokens, potentialPos+1) + variableNode, potentialPos, e = p.parseVariableNode(tokens, potentialPos+1) if e != nil { err = e return @@ -890,7 +890,7 @@ func (p *Parser) ParseDeclarationNode(tokens []Token, pos int) (result Declarati return } -func (p *Parser) ParseBeginBlock(tokens []Token, pos int) (result BeginBlockNode, newPos int, err error) { +func (p *Parser) parseBeginBlock(tokens []Token, pos int) (result BeginBlockNode, newPos int, err error) { // BEGIN END pos, err = p.checkToken("begin block", []string{"begin"}, pos, tokens) if err != nil { @@ -899,7 +899,7 @@ func (p *Parser) ParseBeginBlock(tokens []Token, pos int) (result BeginBlockNode pos++ // get the generateable statements - generateableStatements, potentialPos, e := p.ParseAlwaysStatements(tokens, pos) + generateableStatements, potentialPos, e := p.parseAlwaysStatements(tokens, pos) if e != nil { err = e return @@ -916,7 +916,7 @@ func (p *Parser) ParseBeginBlock(tokens []Token, pos int) (result BeginBlockNode newPos = pos return } -func (p *Parser) ParseIfBlock(tokens []Token, pos int) (result IfBlockNode, newPos int, err error) { +func (p *Parser) parseIfBlock(tokens []Token, pos int) (result IfBlockNode, newPos int, err error) { // IF LPAREN RPAREN [ELSE ] // get if pos, err = p.checkToken("if block", []string{"if"}, pos, tokens) @@ -933,7 +933,7 @@ func (p *Parser) ParseIfBlock(tokens []Token, pos int) (result IfBlockNode, newP pos++ // get expression - expression, potentialPos, e := p.ParseExpression(tokens, pos) + expression, potentialPos, e := p.parseExpression(tokens, pos) if e != nil { err = e return @@ -949,7 +949,7 @@ func (p *Parser) ParseIfBlock(tokens []Token, pos int) (result IfBlockNode, newP pos++ // get generateable statement - generateableStatement, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) + generateableStatement, potentialPos, e := p.parseAlwaysStatement(tokens, pos) if e != nil { err = e return @@ -962,7 +962,7 @@ func (p *Parser) ParseIfBlock(tokens []Token, pos int) (result IfBlockNode, newP if e == nil { pos = potentialPos + 1 // get always statement - generateableStatement, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) + generateableStatement, potentialPos, e := p.parseAlwaysStatement(tokens, pos) if e != nil { err = e return @@ -974,7 +974,7 @@ func (p *Parser) ParseIfBlock(tokens []Token, pos int) (result IfBlockNode, newP newPos = pos return } -func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, newPos int, err error) { +func (p *Parser) parseForBlock(tokens []Token, pos int) (result ForBlockNode, newPos int, err error) { // -> FOR LPAREN [] SEMICOLON [] SEMICOLON [] RPAREN // get for pos, err = p.checkToken("for block", []string{"for"}, pos, tokens) @@ -989,7 +989,7 @@ func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, ne } pos++ // get assignment_without_semicolon, optionally - assignmentWithoutSemicolon, potentialPos, e := p.ParseAssignmentNodeWithoutSemicolon(tokens, pos) + assignmentWithoutSemicolon, potentialPos, e := p.parseAssignmentNodeWithoutSemicolon(tokens, pos) if e == nil { result.Initializer = &assignmentWithoutSemicolon pos = potentialPos @@ -1001,7 +1001,7 @@ func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, ne } pos++ // get expr, optionally - expr, potentialPos, e := p.ParseExpression(tokens, pos) + expr, potentialPos, e := p.parseExpression(tokens, pos) if e == nil { result.Condition = &expr pos = potentialPos @@ -1013,7 +1013,7 @@ func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, ne } pos++ // get assignment_without_semicolon, optionally - assignmentWithoutSemicolon, potentialPos, e = p.ParseAssignmentNodeWithoutSemicolon(tokens, pos) + assignmentWithoutSemicolon, potentialPos, e = p.parseAssignmentNodeWithoutSemicolon(tokens, pos) if e == nil { result.Incrementor = &assignmentWithoutSemicolon pos = potentialPos @@ -1026,7 +1026,7 @@ func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, ne } pos++ // get statement - body, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) + body, potentialPos, e := p.parseAlwaysStatement(tokens, pos) if e != nil { err = e return @@ -1036,9 +1036,9 @@ func (p *Parser) ParseForBlock(tokens []Token, pos int) (result ForBlockNode, ne newPos = pos return } -func (p *Parser) ParseCaseNode(tokens []Token, pos int) (result CaseNode, newPos int, err error) { +func (p *Parser) parseCaseNode(tokens []Token, pos int) (result CaseNode, newPos int, err error) { // -> { COMMA } COLON - expr, pos, err := p.ParseExpression(tokens, pos) + expr, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -1049,7 +1049,7 @@ func (p *Parser) ParseCaseNode(tokens []Token, pos int) (result CaseNode, newPos for e == nil { pos = potentialPos + 1 // get expr - expr, pos, err = p.ParseExpression(tokens, pos) + expr, pos, err = p.parseExpression(tokens, pos) if err != nil { return } @@ -1065,7 +1065,7 @@ func (p *Parser) ParseCaseNode(tokens []Token, pos int) (result CaseNode, newPos pos++ // get alwaysable statement - body, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) + body, potentialPos, e := p.parseAlwaysStatement(tokens, pos) if e != nil { err = e return @@ -1077,7 +1077,7 @@ func (p *Parser) ParseCaseNode(tokens []Token, pos int) (result CaseNode, newPos } // -> CASE LPAREN RPAREN {} [ DEFAULT COLON ] ENDCASE -func (p *Parser) ParseCaseBlock(tokens []Token, pos int) (result CaseBlock, newPos int, err error) { +func (p *Parser) parseCaseBlock(tokens []Token, pos int) (result CaseBlock, newPos int, err error) { // get case pos, err = p.checkToken("case block", []string{"case"}, pos, tokens) if err != nil { @@ -1093,7 +1093,7 @@ func (p *Parser) ParseCaseBlock(tokens []Token, pos int) (result CaseBlock, newP pos++ // get expr - expr, pos, err := p.ParseExpression(tokens, pos) + expr, pos, err := p.parseExpression(tokens, pos) if err != nil { return } @@ -1107,11 +1107,11 @@ func (p *Parser) ParseCaseBlock(tokens []Token, pos int) (result CaseBlock, newP pos++ // get cases - caseNode, potentialPos, e := p.ParseCaseNode(tokens, pos) + caseNode, potentialPos, e := p.parseCaseNode(tokens, pos) for e == nil { result.Cases = append(result.Cases, caseNode) pos = potentialPos - caseNode, potentialPos, e = p.ParseCaseNode(tokens, pos) + caseNode, potentialPos, e = p.parseCaseNode(tokens, pos) } // get default, optionally @@ -1125,7 +1125,7 @@ func (p *Parser) ParseCaseBlock(tokens []Token, pos int) (result CaseBlock, newP } pos++ // get alwaysable statement - body, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) + body, potentialPos, e := p.parseAlwaysStatement(tokens, pos) if e != nil { err = e return @@ -1145,39 +1145,39 @@ func (p *Parser) ParseCaseBlock(tokens []Token, pos int) (result CaseBlock, newP return } -func (p *Parser) ParseAlwaysStatement(tokens []Token, pos int) (result AlwaysStatement, newPos int, err error) { +func (p *Parser) parseAlwaysStatement(tokens []Token, pos int) (result AlwaysStatement, newPos int, err error) { // -> | | | | | - beginResult, potentialPos, e := p.ParseBeginBlock(tokens, pos) + beginResult, potentialPos, e := p.parseBeginBlock(tokens, pos) if e == nil { result.BeginBlock = &beginResult pos = potentialPos } else { - interiorResult, potentialPos, e := p.ParseInteriorStatement(tokens, pos) + interiorResult, potentialPos, e := p.parseInteriorStatement(tokens, pos) if e == nil { result.InteriorNode = &interiorResult pos = potentialPos } else { - forResult, potentialPos, e := p.ParseForBlock(tokens, pos) + forResult, potentialPos, e := p.parseForBlock(tokens, pos) if e == nil { result.ForBlock = &forResult pos = potentialPos } else { - ifResult, potentialPos, e := p.ParseIfBlock(tokens, pos) + ifResult, potentialPos, e := p.parseIfBlock(tokens, pos) if e == nil { result.IfBlock = &ifResult pos = potentialPos } else { - functionResult, potentialPos, e := p.ParseBuiltinFunctionCall(tokens, pos) + functionResult, potentialPos, e := p.parseBuiltinFunctionCall(tokens, pos) if e == nil { result.FunctionNode = &functionResult pos = potentialPos } else { - delayNode, potentialPos, e := p.ParseDelayStatement(tokens, pos) + delayNode, potentialPos, e := p.parseDelayStatement(tokens, pos) if e == nil { result.DelayNode = &delayNode pos = potentialPos } else { - caseNode, potentialPos, e := p.ParseCaseBlock(tokens, pos) + caseNode, potentialPos, e := p.parseCaseBlock(tokens, pos) if e == nil { result.CaseNode = &caseNode pos = potentialPos @@ -1193,17 +1193,17 @@ func (p *Parser) ParseAlwaysStatement(tokens []Token, pos int) (result AlwaysSta newPos = pos return } -func (p *Parser) ParseAlwaysStatements(tokens []Token, pos int) (result []AlwaysStatement, newPos int, err error) { - generateableStatement, potentialPos, e := p.ParseAlwaysStatement(tokens, pos) +func (p *Parser) parseAlwaysStatements(tokens []Token, pos int) (result []AlwaysStatement, newPos int, err error) { + generateableStatement, potentialPos, e := p.parseAlwaysStatement(tokens, pos) for e == nil { result = append(result, generateableStatement) pos = potentialPos - generateableStatement, potentialPos, e = p.ParseAlwaysStatement(tokens, pos) + generateableStatement, potentialPos, e = p.parseAlwaysStatement(tokens, pos) } newPos = pos return } -func (p *Parser) ParseGenerate(tokens []Token, pos int) (result GenerateNode, newPos int, err error) { +func (p *Parser) parseGenerate(tokens []Token, pos int) (result GenerateNode, newPos int, err error) { // -> GENERATE ENDGENERATE // get generate pos, err = p.checkToken("generate", []string{"generate"}, pos, tokens) @@ -1213,7 +1213,7 @@ func (p *Parser) ParseGenerate(tokens []Token, pos int) (result GenerateNode, ne pos++ // get generateable_statements - generateableStatements, potentialPos, e := p.ParseAlwaysStatements(tokens, pos) + generateableStatements, potentialPos, e := p.parseAlwaysStatements(tokens, pos) if e != nil { err = e return @@ -1233,7 +1233,7 @@ func (p *Parser) ParseGenerate(tokens []Token, pos int) (result GenerateNode, ne } //